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

17 次查看(过去 30 天)
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 个评论
Ameer Hamza
Ameer Hamza 2020-3-16
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 2020-3-19
No, this doesn't work. The variable frames remains empty.

请先登录,再进行评论。

回答(1 个)

Aditya Patil
Aditya Patil 2020-3-16
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 个评论
Vincent K
Vincent K 2020-3-19
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 2021-8-3
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.

请先登录,再进行评论。

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by