Can't open H.264 video in Matlab 2019b

15 views (last 30 days)
Vincent K
Vincent K on 13 Mar 2020
Commented: Adam Danz on 3 Aug 2021
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
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.
Vincent K
Vincent K on 19 Mar 2020
No, this doesn't work. The variable frames remains empty.

Sign in to comment.

Answers (1)

Aditya Patil
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
Vincent K
Vincent K on 19 Mar 2020
Reinstalling Matlab 2019b didn't help. I use Windows 10. Trying
vidObj = vision.VideoFileReader(videoPath);
while ~isDone( vidObj )
frame = step( vidObj ) ;
end
result in the error
Error using VideoFileReader/step
Reading from the file timed-out
Trying
frames = importdata('DJI_0060.MP4');
results in an empty variable.
Maybe my Windows system is malconfigured? Or what else could be the problem?
Adam Danz
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.

Sign in to comment.

Tags

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!