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 16th March 2011, 00:31   #1  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
How can I correct the PAR in an MP4?

Hi, I have an MP4 file created by Nero Recode that has an incorrect pixel aspect ratio (10:11 when it should be the oddball 3:4).

I want to correct the file to indicate the right PAR, and ideally avoid reencoding the video/audio information in any other way.

MP4, Nero Digital H.264/AVC High Profile with DD2.0 AC/3 audio.

I tried using mp4box, and it did change the PAR flagged at the mp4 container level, but the resulting video has very low compatibility with players on my system (only VLC plays it with the new PAR; directshow players all use the old PAR, and Quicktime generates an error and refuses to play it).


Got in this situation apparently due to bugs in Windows Media Center (the DVD is of a digital TV recording, burned from WMC, and WMC encoded it wrong. Nero was able to crop as needed but not correct the PAR).

I see Handbrake options that appear to allow me to set the correct PAR, but it looks like Handbrake will reencode the video - requires me to set a bitrate/quality.


Anyone know how I can accomplish this?
Thanks!
eathasa is offline   Reply With Quote
Old 16th March 2011, 01:10   #2  |  Link
upyzl
zj262144
 
upyzl's Avatar
 
Join Date: Sep 2010
Posts: 105
Hm... It seems that roozhou's ffmpeg may help you: http://forum.doom9.org/showthread.php?t=152419
__________________
MPC-HC 1.7.8 / LAV Filters 0.64+ (tMod) / XySubFilter 3.1.0.705 / madVR 0.87.14

Direct264 Mod (src & win32 builds): code.google.com/p/direct264umod (maybe outdated)
upyzl is offline   Reply With Quote
Old 21st March 2011, 12:30   #3  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
Thanks upyzl!

Strange to me how hard to find this feature is. That tool does appear to have the feature I'm looking for, but unfortunately it didn't work right for me. The project is non-critical,... it wasn't supposed to be a "project" to begin with! When I have the time to play with it some more I will ask roozhou who appears to be active here and actively developing his ffmpeg fork.
Another alternative might be re-ripping the DVD, if any encoding/ripping software can better handle PAR correction (with the ability to crop the image) at that stage.

For historical accuracy, the Quicktime trial I mention in my first post is invalid: The original mp4 generated by Nero generates the same error as the modified mp4 I noticed the error with. Perhaps due to the encoding features I enabled (8x8 transform / High Profile? AC-3 audio?) -- Anyway, that is an unrelated (and unimportant) issue.
eathasa is offline   Reply With Quote
Old 21st March 2011, 13:32   #4  |  Link
b66pak
Registered User
 
b66pak's Avatar
 
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
for qt and h264+ac3 change the extension from .mp4 to .m4v...
_
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note...
Visit The Land Of Dracula (Romania - EU)!
b66pak is offline   Reply With Quote
Old 21st March 2011, 15:00   #5  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,248
You can also change the PAR value of AVC video streams using YAMB...
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 21st March 2011, 15:55   #6  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
Oh, good to know re. Quicktime!
I considered YAMB, but it's a front-end for mp4box, which only changes the PAR at the container level, and the resulting mp4 doesn't play with the the corrected PAR in most video players that way -- at least on my system.
eathasa is offline   Reply With Quote
Old 21st March 2011, 16:06   #7  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,248
Quote:
Originally Posted by eathasa View Post
Oh, good to know re. Quicktime!
I considered YAMB, but it's a front-end for mp4box, which only changes the PAR at the container level, and the resulting mp4 doesn't play with the the corrected PAR in most video players that way -- at least on my system.
You are wrong...

YAMB is able to change PAR values at the video stream level

QuicktimePro and MP4muxer is able to change PAR values at the container level
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 22nd March 2011, 04:06   #8  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
I got the understanding that mp4box (and yamb) change the PAR at the container level from the following 2009 discussion thread: http://forum.videohelp.com/threads/3...ut-re-encoding -- at least two posters made that statement.

My experience seemed to reinforce that understanding: I used a March 2, 2011 Kurtnoise compile of mp4box (v0.4.6-DEV-rev2735), and changing the PAR on my mp4 worked only if the mp4 was play in VLC, but not in any other player. Also, it applied the change almost instantly, whereas the roozhou ffmpeg fork took some time to process the whole file and change all the SPS records, but the resulting file did NOT show the PAR correction in VLC -- it was ONLY corrected in directshow players! (I'm simplifying my results with this ffmpeg, as there were other issues with my results too).

In any case, neither program seemed to correct it and create a fully compatible, fully corrected file. Using them in combination, in either order, did not solve the issues either.
eathasa is offline   Reply With Quote
Old 22nd March 2011, 04:18   #9  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
Actually the term "video stream level" is quite possibly more accurate as to what mp4box (and yamb) does for the PAR than the term "container level" I've seen mentioned in a few places including the videohelp link I posted;

YES, when I tried mp4box, I did specify the video stream on the commandline. Nonetheless, it applied the change almost instantly, indicating it was not changed THROUGHOUT the videostream -- I suppose that would be at the "SPS level" that the ffmpeg fork tries to address.
eathasa is offline   Reply With Quote
Old 22nd March 2011, 06:10   #10  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
@eathasa
What problem did you get with ffmpeg? ffmpeg changes PAR in both "SPS level" and container headers. Since the modifying PAR in SPS may change stream length, it is not possible to apply in-place but a full remux is required.
roozhou is offline   Reply With Quote
Old 22nd March 2011, 11:16   #11  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
Hi roozhou --
What a helpful forum this is
Thank you for your work on the ffmpeg fork - it seems to be filling a hole!

I was finally able to mux a file that plays with the correct aspect ratio in all the players I tried -- yay!

I have some fairly minor concerns with the output from ffmpeg that I will explain to you .. but I will get back to you on that. I just spent a lot of time typing a message here detailing all that but accidentally hit a link with my mouse and when I hit "back" in my browser to get back to this thread, my detailed message was gone. :/...

One significant oddity/confusion for me was that the SAR had to be set to 3:4 to get my desired PAR of 3:4. I also used the aspect command line option to set DAR to 4:3 (I got inconsistent playback aspects in different players without that)

SAR × PAR = DAR (Pixel aspect ratio - Wikipedia)
DAR=4:3, PAR=3:4
Solving for SAR:
SAR = 4:3/3:4 = 16:9

The same Wikipedia article explains that SAR is simply the pixel ratio (pixels wide/pixels high); in my case:
SAR = 704:396 = 16:9

Does SAR have a different meaning to ffmpeg?
eathasa is offline   Reply With Quote
Old 22nd March 2011, 11:21   #12  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by eathasa View Post
Does SAR have a different meaning to ffmpeg?
For x264 and FFmpeg (and most other modern video tools),

SAR = Sample Aspect Ratio = Pixel Aspect Ratio

Last edited by nm; 22nd March 2011 at 11:24.
nm is offline   Reply With Quote
Old 22nd March 2011, 11:40   #13  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
I recall someone in this forum introduced FAR (Frame AR) to avoid confusion between Sample AR and Source AR.
roozhou is offline   Reply With Quote
Old 22nd March 2011, 11:54   #14  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Just use the frame size. Stop the TLAs
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 22nd March 2011, 12:32   #15  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
Ah, well, that would explain it

Next question: Why is it necessary to set both the sample aspect ratio and the display aspect ratio -- if either one is honored, the other is a given. Is there a reason that both values are stored and can be inconsistent with each other?
eathasa is offline   Reply With Quote
Old 22nd March 2011, 12:50   #16  |  Link
eathasa
Registered User
 
Join Date: May 2006
Posts: 14
J_Darnley - haha, I had to think about that for a minute. And yes, they make things more complicated, especially when you invent new ones, but they do save on typing, too. For command lines arguments, I like it when both a long form and short form argument are defined. For general usage, though, a minimum of abbreviations is best, since communication is the objective.

I assume sample aspect ratio was named that because the concept of "sample" was somehow better or more forward-thinking than pixel, but pixel is the common person's term for the addressable picture elements (hey, how about APE ), and I would think I knew what "PAR" was in this context without prior experience or reading the manual.
eathasa is offline   Reply With Quote
Old 22nd March 2011, 19:35   #17  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by eathasa View Post
Ah, well, that would explain it
Next question: Why is it necessary to set both the sample aspect ratio and the display aspect ratio -- if either one is honored, the other is a given. Is there a reason that both values are stored and can be inconsistent with each other?
Because sar is not always honored by players. Some players (e.g. QuickTime) requires a valid DAR value in MP4.

IMO DAR should not be set unless there is no place to put sar in the bitstream(e.g. WMV3). So ffmpeg build from my fork does not write DAR for mkv since no player requires DAR in MKV.
roozhou is offline   Reply With Quote
Old 22nd March 2011, 20:06   #18  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
That violates the Matroska spec as then the DisplayHeight and DisplayWidth are to be interpreted as PixelHeight and PixelWidth. A spec compliant player would have to display the file as SAR 1:1.
sneaker_ger is offline   Reply With Quote
Old 22nd March 2011, 20:28   #19  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,248
Quote:
Originally Posted by roozhou View Post
Because sar is not always honored by players. Some players (e.g. QuickTime) requires a valid DAR value in MP4.
Actually, Quicktime player does not respect aspect ratio signalling placed at the "video stream level" at all. It looks for it at the "container level"... The Apple guys refer to it as a "Transformation" option.

And in-case any of you are interested (with the exception of the Apple TV player) not a single hardware player respects "container level" aspect ratio signalling whether it be .MKV, .MOV or .MP4!


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 22nd March 2011, 21:54   #20  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by SeeMoreDigital View Post
And in-case any of you are interested (with the exception of the Apple TV player) not a single hardware player respects "container level" aspect ratio signalling whether it be .MKV, .MOV or .MP4!
PopCornHour C-200 respects mkv AR info for h.264 AFAIK.
sneaker_ger is offline   Reply With Quote
Reply

Tags
h.264, mp4, par, pixel aspect ratio

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 01:43.


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