missing frames in mp4
Show older comments
The attached movie-file has about 38 frames. I can see them with VLC and with MPC-HC. Frames are 20ms appart as seen in the timestamps at the bottom of each image. Matlab however, only shows half of these frames every 40ms. How can I get all frames?
Answers (1)
YT
on 31 Oct 2018
From the documentation on VideoReader
v = VideoReader('stefan.mp4');
currAxes = axes;
while hasFrame(v)
vidFrame = readFrame(v);
image(vidFrame, 'Parent', currAxes);
currAxes.Visible = 'off';
pause(1/v.FrameRate);
end
7 Comments
Stefan Monstein
on 1 Nov 2018
Hugo Lehoux
on 22 Feb 2021
Did you find a solution for this issue? I'm having the same problem
Stefan Monstein
on 23 Feb 2021
Hugo Lehoux
on 12 Mar 2021
Hello Stefan, thanks for the quick response. I have downloaded the example file you provided and even with VLC I am only seeing specific frames every 40 ms as well...
In my case, the videos are interlaced and Matlab only shows one of the two fields, but VLC does show the interlaced frames. The solution I found so far is to convert the files using another software like Prism. When I do that, then Matlab correctly reads the interlaced frames. The issue seems to come from the way the video is encoded, and the way Matlab and other softwares decode it, I guess...
Stefan Monstein
on 12 Mar 2021
Hugo Lehoux
on 12 Mar 2021
I have done some research, it appears one codec that is problematic is the Motion JPEG (MJPG or MJPEG). I have not tested all of them of course, and it seems I cannot get information on the file you provided on Matlab for some reason, so I don't know if it is encoded in MJPEG, but if that is the case, then that could explain why Matlab only reads half the frames. I have checked again and VLC does correctly read the interlaced frames on this file.
Constantino Carlos Reyes-Aldasoro
on 9 Feb 2023
I had a similar problem, I changed from mp4 to AVI and now I can see all my frames. The size of the video tripled, but I have all the frames.
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!