Can't open H.264 video in Matlab 2019b
15 views (last 30 days)
Show older comments
I have a very simple but annoying problem. Since I upgraded to Matlab 2019b the following code doesn't work anymore:
reader = VideoReader(videoPath);
frame = readFrame(reader);
I always get the error "No more frames available to read from file.". The video is a normal .mp4 file with h.264 codec. I can open it with every other Matlab version and video player without problems.
So what happened in Matlab 2019b that this code doesn't work anymore and how can I fix it?
4 Comments
Ameer Hamza
on 16 Mar 2020
Even with this video, I got no error, the MATLAB was able to read the video file just fine. However, I am running it on macOS.
You can try to use the following method as an alternate method until the issue is solved.
frames = importdata('DJI_0060.MP4');
Let us know if this works.
Answers (1)
Aditya Patil
on 16 Mar 2020
I was not able to replicate this issue with few sample .mp4 files with h.264 encoding. Without the file which creates the issue, it won’t be possible to solve the problem. Can you please provide the file which is causing an issue?
As a possible workaround, you can try to convert the file into another format/codec. Alternately, if you have the Computer Vision toolbox, you can use the following workaround,
vidObj = vision.VideoFileReader(videoPath);
while ~isDone( vidObj )
frame = step( vidObj ) ;
end
4 Comments
Adam Danz
on 3 Aug 2021
I'm having the same exact problem described by Vincent K above using windows 10. I've converted the mp4 file to avi and to MPEG-4 and the problem persists. When I try over and over and again with the same file on the same system, sometimes it works but ~90% of the time it does not work. Using Matlab R2021a.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!