View Full Version : x264 crf and Matlab processing
ssuave
15th December 2013, 18:01
Hi,
Did anyone experienced the following problem or know how to resolve it?
1.
I encode a video using the following:
>> ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.avi
2. The generated *.avi needs to processed by using Matlab. One reason is to compute VQM metric of it.
So, I do like this:
>>vid1=VideoReader('*.avi');
>> frame_vid1=read(vid1,1);
Following error occurs:
Error using VideoReader/read
The frame index requested is beyond the end of the file.
What can be the solution?
nhakobian
15th December 2013, 19:17
This is most likely due to H.264/AVC being muxed into an AVI file. AVI requires "hacks" to play formats with b-frames as the frames are not stored in the same order that they are displayed. Either ffmpeg doesnt apply these "hacks" or the AVI reader on your system cannot understand these changes (or both).
Does matlab support opening MP4 files or MKV files? If not, you should complain to the matlab people since the AVI format is about 10 years out of date.
LoRd_MuldeR
15th December 2013, 20:57
Can Matlab not read MP4 files by now? If not, you could first decompress the H.264 file to a lossless format, like HuffYUV. This should work fine from AVI.
BTW: You can calculate VQM with the MSU Video Quality Tool (http://compression.ru/video/quality_measure/vqmt_download_en.html#free), which supports Avisyth input. So you can easily load pretty much everything, e.g. via FFMS2 plug-in or via DirectShowSource.
ssuave
16th December 2013, 15:31
Thanks for the comments!
By the way, same happens if I encode it to a '*.mp4' file.
nhakobian
16th December 2013, 18:03
Thanks for the comments!
By the way, same happens if I encode it to a '*.mp4' file.
Hmm, perhaps matlab doesn't have a H.264/AVC decoder built in then (and can't fallback to use the OS's decoder). Including one would require paying licensing fees back to the MPEG-LA, so maybe that is the case.
I would think they would put in an error message that was a little more descriptive, though.
LoRd_MuldeR
16th December 2013, 18:26
Well, according to the docs (http://www.mathworks.de/de/help/matlab/ref/videoreaderclass.html) they support quite a lot:
All Platforms: AVI (.avi), Motion JPEG 2000 (.mj2)
All Windows: MPEG-1 (.mpg), Windows Media® Video (.wmv, .asf, .asx), and any format supported by Microsoft® DirectShow®.
Windows 7: MPEG-4, including H.264 encoded video (.mp4, .m4v), Apple QuickTime Movie (.mov), and any format supported by Microsoft Media Foundation.
Interesting question is:
What technology do they use to decode AVI files? If it's supported on all platforms, it must be an internal decoder. But then only specific formats are supported. The docs don't have any details on this.
Maybe they even support "raw" (uncompressed) AVI files only?
nhakobian
17th December 2013, 03:28
Its also possible that ssuave isnt running on windows. Matlab does run on unix/linux and OS X.
If thats the case, you might have to poke Mathworks and see if they are willing to maybe add that in to their next version.
benwaggoner
24th December 2013, 01:18
Its also possible that ssuave isnt running on windows. Matlab does run on unix/linux and OS X.
Or Windows <7. Windows 7 has a built-in H.264 decoder, but earlier versions didn't. I'd hope that MatLab could at least use QuickTime on Mac and DirectShow on Windows.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.