Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th December 2013, 18:01   #1  |  Link
ssuave
Registered User
 
ssuave's Avatar
 
Join Date: Jan 2012
Location: Sweden
Posts: 18
x264 crf and Matlab processing

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?
ssuave is offline   Reply With Quote
Old 15th December 2013, 19:17   #2  |  Link
nhakobian
Registered User
 
Join Date: Oct 2009
Location: San Francisco, CA
Posts: 101
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.
nhakobian is offline   Reply With Quote
Old 15th December 2013, 20:57   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,208
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, which supports Avisyth input. So you can easily load pretty much everything, e.g. via FFMS2 plug-in or via DirectShowSource.
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 15th December 2013 at 21:58.
LoRd_MuldeR is offline   Reply With Quote
Old 16th December 2013, 15:31   #4  |  Link
ssuave
Registered User
 
ssuave's Avatar
 
Join Date: Jan 2012
Location: Sweden
Posts: 18
Thanks for the comments!
By the way, same happens if I encode it to a '*.mp4' file.
ssuave is offline   Reply With Quote
Old 16th December 2013, 18:03   #5  |  Link
nhakobian
Registered User
 
Join Date: Oct 2009
Location: San Francisco, CA
Posts: 101
Quote:
Originally Posted by ssuave View Post
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.
nhakobian is offline   Reply With Quote
Old 16th December 2013, 18:26   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,208
Well, according to the docs they support quite a lot:
Quote:
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?
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 16th December 2013 at 18:31.
LoRd_MuldeR is offline   Reply With Quote
Old 17th December 2013, 03:28   #7  |  Link
nhakobian
Registered User
 
Join Date: Oct 2009
Location: San Francisco, CA
Posts: 101
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.
nhakobian is offline   Reply With Quote
Old 24th December 2013, 01:18   #8  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 3,737
Quote:
Originally Posted by nhakobian View Post
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.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Reply

Tags
matlab, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.