Image Displacement with VideoReader
Show older comments
Hi all, I am trying to read a video with Matlab 2015a using VideoReader, but the frames seem to be distorted. In some frames, the last few columns are displaced to the beginning of the image, causing the image to shift to the right. However, it seems to only do that for certain frames, and to a different degree on each frame that shows a shift (i.e. not a consistent number of columns that are displaced). The video (.avi) plays normally in media players.
I have included my code below:
[X,path] = uigetfile({'*.avi';'*.mpeg'}, 'Select Movie file','MultiSelect','off');
addpath(path);
vidObj = VideoReader(X);
NumberOfFrames = vidObj.Duration * vidObj.FrameRate
mov = struct('cdata',zeros(vidObj.Height,vidObj.Width,3,'uint8'),'colormap',[]);
mov = read(vidObj,'native');
I also tried reading using a while loop:
k = 1;
while hasFrame(vidObj)
mov(k) = readFrame(vidObj);
k = k+1;
end
And a for loop:
for k = 1:NumberOfFrames
mov(k).cdata = read(vidObj,k);
end
But they both gave the same result. Has anyone ever encountered this? Any advice would be appreciated.
1 Comment
Dinesh Iyer
on 28 Jul 2015
This looks like a file specific issue and not a generic issue with VideoReader as it works fine for files that ship with MATLAB such as xylophone.mp4.
Can you upload the file? Which platform are you working on? Which player have you viewed this file? Even a screenshot of the distorted output will be helpful.
Answers (0)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!