VideoReader problem - Xvid video compression

I have a video which is compressed using the xvid video compressor. I am using the VideoReader function to open the file and am processing video frame by frame. Unfortunately, I have found that with the xvid compressed video every second frame is green. On doing some testing, I found that it isn't the actual frame in the file that is incorrect and it is something to do with reading the movie object. For instance, if I read the same frame consecutively, the first time I read it the image comes out as expected and the second time I read the same frame, the image comes out with all pixels green. Is this a bug in VideoReader? I am using a Mac operating system, but have tested this and found the same problem in both Windows 32 and 64 bit.
Details on the file are as follows -
General Settings:
Duration = 11.6117
Name = test.avi
Path = /Users/GL/Documents/Data
Tag =
Type = VideoReader
UserData = []
Video Settings:
BitsPerPixel = 24
FrameRate = 81.5559
Height = 544
NumberOfFrames = 947
VideoFormat = RGB24
Width = 768

回答 (1 件)

Shawn Fernandes
Shawn Fernandes 2018 年 3 月 27 日

0 投票

Hi,
You would have to make use of the while loop with the 'hasFrame' and 'readFrame' option.
movie = VideoReader('test.avi');
i=1;
while hasFrame(movie)
video_data(i).cdata = readFrame(movie);
i=i+1;
end
Reference : https://www.mathworks.com/help/matlab/ref/videoreader.readframe.html
Tested on Matlab 2018a Windows 10.
Note: Installed ffdshow and x264 codecs separetely
https://sourceforge.net/projects/ffdshow-tryout/
https://sourceforge.net/projects/x264vfw/

2 件のコメント

Walter Roberson
Walter Roberson 2018 年 3 月 27 日
Did you test with an xvid video specifically?
Note: back when the question was asked in 2012, readFrame() did not exist; it was added in R2014b.
Shawn Fernandes
Shawn Fernandes 2018 年 3 月 28 日
Hi Walter,
This is the screenshot of the video file player when played on VLC player.
Thanks,

サインインしてコメントする。

質問済み:

2012 年 1 月 23 日

コメント済み:

2018 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by