VideoReader problem - Xvid video compression

11 次查看(过去 30 天)
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
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,

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by