Image Displacement with VideoReader

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

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.

Sign in to comment.

Answers (0)

Asked:

on 28 Jul 2015

Commented:

on 28 Jul 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!