Reading video file compressed losslessly with x264

4 次查看(过去 30 天)
As the title suggests, I have a problem reading video frames from a video file compressed losslessly with x264. I am using MATLAB 2014b.
I have used x264 lossless compression in VirtualDub. The result is a video file that plays fine in VLC and can also be reopened in VirtualDub. I can also succesfully create a VideoReader object referencing to this video file. The VideoReader object gives me the correct video properties like FrameRate, Width, Height, and so forth. It even has the correct NumberOfFrames property.
However, when I first try to read frames from the object, MATLAB generates an error:
Error using VideoReader/readFrame (line 105)
No more frames available to read from file.
The same happens when I try the older command "read" and explicitly refer to frames I want to read (i.e. the first frame or the last frame, using Inf).
Interestingly, when I compress the same source video file with x264 and use the highest quality setting, i.e. almost lossless while keeping the other settings the same, then MATLAB is able to read frames from the compressed video.
Is that a bug? Do I need to adjust some settings in my codecs or is there another workaround?
Thanks in advance!
Till

回答(2 个)

Sergey Salishev
Sergey Salishev 2018-5-24
It seems that the problem is due to pixel format yuv444.
I converted using the ffmpeg with the following command line and it magically works
ffmpeg -i %1.mkv -c:v libx264 -pix_fmt yuv420p -map 0:v:%2 %1_%2.mkv

Walter
Walter 2019-6-19
THe recommendation by Sergey did not work for me on R2018a

产品

Community Treasure Hunt

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

Start Hunting!

Translated by