Log in

View Full Version : changing Aspect Ratio of AVC streams in .mp4


Pages : 1 [2]

charleski
22nd October 2005, 23:16
After much gnashing of teeth I've managed to get this working for large files produced from Nero Recode.

I had a file that I'd compressed at 3+Mbps and was over 2Gb, but after encoding it I noticed that the aspect ratio had come out wrong, probably because of a wrong decision upstream from the final encode. I wanted to retain the full vertical resolution that I had but needed an anamorphic sqeeeze that wasn't the standard 16:9 one. After much FAQ-reading and googling it looked like the best bet was to try to manipulate the flags in the .mp4 container rather than re-encode, as putting a resize in before re-encoding would have lost me some vertical scan-lines. Unfortunately none of the tools mentioned in the MP4 FAQ, including ARChange from here, worked on my large file, they all crashed out or gave assertion errors.

In a fit of madness I decided to try just hex-editing the file to change the flags by hand. Hmm, bad idea, I managed to waste many hours trying to figure that one out. Documentation on the MP4 atoms seems a bit skimpy. I've poured over mp4-layout.txt (http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt), but couldn't get anywhere with that (I couldn't find any explanation of how to decode the SPS and PPS fields) . So I went back to ARChange, which did at least crash with a readable assertion field. After a bit of fiddling and debugging I realised that the file offsets were stored as longs and must be overflowing. I changed every offset and length variable to a 64bit integer, and now it works, on my file at least, when using Nero Showtime to play the file (I tried the QT7 player, but it doesn't recognise the AR flags in avcC and it can't play Nero's CinemaAVC profile properly anyway).

I thought I'd upload the altered code back here, as this has certainly been a life-saver (many thanks hhanh00!), but there might be others with a similar problem. I might have altered some varaible that were fine as longs, but decided to do them all to be on the safe side. I suspect the problem with integer overflow is the reason that none of the GPAC tools etc managed to read anything from the file either.

[Edit: speeling]

SeeMoreDigital
24th October 2005, 15:35
You guys might be happy to know....

After a request from Kurtnoise13..... Jean Le Feuvre (aka: jeanlf), has included the ability to change the PAR of both MPEG-4 SP/ASP and AVC streams, to MP4Box ;)

More can be read about it here: -

https://sourceforge.net/tracker/?func=detail&atid=571741&aid=1311055&group_id=84101


Cheers

Elias
24th October 2005, 15:37
You guys might be happy to know....

After a request from Kurtnoise13..... Jean Le Feuvre (aka: jeanlf), has included the ability to change the PAR of both MPEG-4 SP/ASP and AVC streams, to MP4Box ;)

More can be read about it here: -

https://sourceforge.net/tracker/?func=detail&atid=571741&aid=1311055&group_id=84101


CheersNow that's pwnage stuff :D Thanks for the notification SMD!

SeeMoreDigital
24th October 2005, 16:06
Now that's pwnage stuff :D Thanks for the notification SMD!Hopefully Jean will be able to include VOBsubs support too!

When this happens, MP4box will be "the dogs nads" :D


Cheers

Elias
24th October 2005, 16:15
Hopefully Jean will be able to include VOBsubs support too!

When this happens, MP4box will be "the dogs nads" :D


CheersWhy do you want VOBsubs in mp4 when we got MPEG-4 Timed Text? :)

Sharktooth
24th October 2005, 16:35
coz only osmo can decode TTXT....

bond
24th October 2005, 16:39
coz only osmo can decode TTXT....wrong. videolan, quicktime and realplayer can do it too ;)

edit and of course haali + vsfilter can do it too!!!

Elias
24th October 2005, 16:47
coz only osmo can decode TTXT....I guess you haven't been in the subtitle forum for a while:

http://forum.doom9.org/showthread.php?t=101047

Enjoy! ;)

SeeMoreDigital
24th October 2005, 17:05
Why do you want VOBsubs in mp4 when we got MPEG-4 Timed Text? :)Recode2 generates streams with VOBsubs for use with NeroDigital certified stand-alone players. And software players - with the aid of Haali's splitter....

Currently, it's not possible to alter NeroDigital streams (ie: add/re-name the chapters, add/remove audio streams etc) using MP4Box if they include VOBsubs.

As you may already know I'm currently beta testing Zensonic's Z500 High Definition Network DVD Media Player, which (as well as other things) will eventually include NeroDigital certification.... Meaning multiple subtitle, audio and chapter support.

As the Z500 has a front vacuum fluorescent display (VFD).... it would be kinda cool to flick thru' the chapters and see the chapter names appear on-screen and/or on the VFD ;)


Cheers

Elias
24th October 2005, 17:10
Recode2 generates streams with VOBsubs for use with NeroDigital certified stand-alone players. And software players - with the aid of Haali's splitter....

Currently, it's not possible to alter NeroDigital streams (ie: add/re-name the chapters, add/remove audio streams etc) using MP4Box if they include VOBsubs.

As you may already know I'm currently beta testing Zensonic's Z500 High Definition Network DVD Media Player, which (as well as other things) will eventually include NeroDigital certification.... Meaning multiple subtitle, audio and chapter support.

As the Z500 has a front vacuum fluorescent display (VFD).... it would be kinda cool to flick thru' the chapters and see the chapter names appear on-screen and/or on the VFD ;) I understand. Personally though, I don't like it when any kind of software breaks specs compliance, and I do not want this feature to be implemented :D

Nero ought to implement Timed Text instead and ditch VOBsubs.

My 2 cents.

leowai
25th October 2005, 04:23
Nero ought to implement Timed Text instead and ditch VOBsubs.
This probably required a special function in the chipset for decode these chars in text. For eng subs should be no problem. What about other languages with thousand of different chars? i.e. Chinese (traditional & Simplified)?

In another words, this make the system much more complex at a very high cost (at this time).

I noticed some mp3 players are capable of displaying lyrics (I got one). However, not all text are "displayable". Some chinese chars can't be displayed!

This technology still needs improvements before it should be merged with MP4 hardware player. I doubt you could still enjoy a movie with crapped subtitles, could you?

Elias
25th October 2005, 08:10
This probably required a special function in the chipset for decode these chars in text. For eng subs should be no problem. What about other languages with thousand of different chars? i.e. Chinese (traditional & Simplified)?

In another words, this make the system much more complex at a very high cost (at this time).

I noticed some mp3 players are capable of displaying lyrics (I got one). However, not all text are "displayable". Some chinese chars can't be displayed!

This technology still needs improvements before it should be merged with MP4 hardware player. I doubt you could still enjoy a movie with crapped subtitles, could you?MPEG-4 Timed Text works as it should when decoded as UTF-8.

stephanV
25th October 2005, 08:50
I doubt there are any SAD's that support unicode.

Elias
25th October 2005, 09:12
I doubt there are any SAD's that support unicode.If they add full support for MPEG-4 Timed Text (which inevitably means Unicode support), I doubt it'll be any problem.

BTW, SAD = Stand Alone DVD?

stephanV
25th October 2005, 09:29
If they add full support for MPEG-4 Timed Text (which inevitably means Unicode support), I doubt it'll be any problem.
That means IF they do that, which is highly doubtful. Maybe some part of unicode will be supported. Most companies don't think twice about breaking standards if it fits their needs better.


BTW, SAD = Stand Alone DVD?
I was trying to type SAP (stand alone player). :o

Elias
25th October 2005, 09:32
That means IF they do that, which is highly doubtful. Maybe some part of unicode will be supported. Most companies don't think twice about breaking standards if it fits their needs better.Yes. DivX is a great example.I was trying to type SAP (stand alone player). :oBang up job, Stephan :D

Kurtnoise
25th October 2005, 11:09
You guys might be happy to know....

After a request from Kurtnoise13..... Jean Le Feuvre (aka: jeanlf), has included the ability to change the PAR of both MPEG-4 SP/ASP and AVC streams, to MP4Box ;)

More can be read about it here: -

https://sourceforge.net/tracker/?func=detail&atid=571741&aid=1311055&group_id=84101

Does anyone have already play with it in the last mp4box ?

I'll included it directly in YAMB asap...

SeeMoreDigital
25th October 2005, 11:49
Does anyone have already play with it in the last mp4box ?

I'll included it directly in YAMB asap...I'm not sure whether anybody (ie: Celtic Druid), has compiled it yet.... Do you know?


Cheers

Kurtnoise
25th October 2005, 12:26
No I don't know but I can provide my own compile (no icl9)...

bond
25th October 2005, 12:36
Does anyone have already play with it in the last mp4box ?hm i tried it already (cd made already a compile) but i dont seem to be able to find the correct syntax when changing the ar of an avc .mp4

on avc:
-add input.mp4#3:par=1:1didnt work: "bad parameters"

-add input.264:par=20:10on an input.264 that had already a par set, worked syntax-wise but the output had no par set in the raw stream

-add input.264:par=20:10on an input.264 that had NO par set, worked perfectly

on asp:
-add input.mp4#3:par=20:10on an input.mp4 that had NO par (1:1) set, worked perfectly

-add input.mp4#3:par=20:10on an input.avi that had already a par set, worked perfectly

-add input.avi:par=20:10on an input.avi that had NO par (1:1) set, worked perfectly

-add input.avi:par=20:10on an input.avi that had already a par set, worked perfectly

-add input.m4v:par=20:10on a raw input.m4v that had NO par (1:1) set, worked perfectly

-add input.m4v:par=20:10on a raw input.m4v that had already a par set, worked perfectly



it seems mp4box writes the par always as "custom par" and doesnt use the shortcuts for 16:9 pal (16:11) which i test for example

SeeMoreDigital
25th October 2005, 12:38
No I don't know but I can provide my own compile (no icl9)...I'm currently using your existing MP4Box compile with your last two YAMB beta's..... So yes please compile away :)

By-the-way. Where are you thinking of putting the "PAR changing" option. Will it be in here?

http://img497.imageshack.us/img497/5299/yambimportsettingsbox3kr.png


Cheers

SeeMoreDigital
25th October 2005, 13:02
hm i tried it already (cd made already a compile) but i dont seem to be able to find the correct syntax when changing the ar of an avc .mp4....

...it seems mp4box writes the par always as "custom par" and doesnt use the shortcuts for 16:9 pal (16:11) which i test for exampleDid you try any of the four main DAR values... ie: 16:15 for 4:3 PAL, 8:9 for 4:3 NTSC, 64:45 for 16:9 PAL or 32:27 for 16:9 NTSC?


Cheers

Kurtnoise
25th October 2005, 13:24
Ok...here is my fresh build (http://kurtnoise.free.fr/mp4tools/MP4Box_20051025.zip).

I only tested the DAR values proposed by SMD at beginning of this thread. And it seems to work fine when we check the tracks infos in mp4box.

Where are you thinking of putting the "PAR changing" option. Will it be in here?
Yes, probably under languages checkbox. There will be some presets (i.e 16:9 PAL, 4:3 PAL, 4:3 NTSC , 16:9 NTSC) + customs where you can write you own values.


on avc:
Code:

-add input.mp4#3:par=1:1

didnt work: "bad parameters"
Wrong syntax...;) Maybe ....
-add input.mp4#trackID=3:par=1:1


Question: which players support these DAR ?

SeeMoreDigital
25th October 2005, 13:53
Question: which players support these DAR ?I've sent DAR samples to many people with MP4 capable stand-alones/devices.... and they work just fine :)

With the exception of the Philips DVP64x range of players....... But I'm of the opinion the Philips (ESS) players are b0rked in a few other ways too.


Cheers

bond
26th October 2005, 10:57
talking about "DAR" is wrong here!!!

we are talking about the aspect ratio of the pixels, aka PAR for ASP or SAR for AVC!

SeeMoreDigital
26th October 2005, 12:15
talking about "DAR" is wrong here!!!

we are talking about the aspect ratio of the pixels, aka PAR for ASP or SAR for AVC!Some of us have been down this road many times before ;)

In the end, whether it be PAR, DAR, SAR... They can all be used to create encodes at the shape you require upon playback in software and hardware players.

As stegre posted some time ago....=========================================================================
Assuming

DAR = display aspect ratio - x/y ratio of physical dimensions (e.g inches or cm - NOT pixels) of display screen
PAR = pixel aspect ratio - x/y ratio of the physical dimensions of a single pixel
SAR = storage aspect ratio - x/y ratio of the #of pixels being encoded, always known from the file

=========================================================================
MPEG-4

DAR = PAR x SAR, where

PAR is based on "aspect_ratio_info" in the Video Object Layer

For aspect_ratio_info values 1 - 5,
PAR = 1:1, 12:11, 10:11, 16:11, and 40:33 respectively.

If aspect_ratio_info = 15, PAR is the custom value:
"par_width" / "par_height"

where par_width & par_height are any two relatively prime integers
between 1 and 255. Those two values are stored in the VOL as well.As you can see above, stegre refers to SAR as being "Storage Aspect Ratio". However, as we know SAR can also be used to refer to the Sample Aspect Ratio (ie: the aspect ratio of the finished encode or sample).

For those interested.... the rest of Stegre's post can be found here (http://forum.doom9.org/showthread.php?p=562532#post562532)....

Cheers

charleski
1st November 2005, 03:17
Has anyone managed to get this feature to work yet? I've been playing around with x264 encoding. Unfortunately it seems that x264 doesn't write a PAR to the video stream (or at least I haven't found an option for that in MeGUI, maybe there's a commandline switch I've overlooked?) so archange is unable to process it.

I've tried muxing with different PAR values using the mp4box compile Kurtnoise linked to, but none of the players I've tried (Nero Showtime, ffdshow, vlc) will recognise the resulting video, though they play the audio part.

bond
1st November 2005, 04:12
x264/megui allows the setting of a sar (aka par)

charleski
1st November 2005, 11:36
Aargh, I've just spotted the SAR field on the Advanced Config tab. Sorry.

EthanoliX
1st November 2005, 13:52
x264/megui allows the setting of a sar (aka par)

Thats right, but if you set the wrong A/R, archange is not able to correct it, at least in my case:

Assertion failed: fVUI || !"VUI not present", file ARChange.cpp, line 565

abnormal program termination

if I try changing the A/R in an mp4, created with x264, using an other A/R than 1:1.

bond
1st November 2005, 14:21
propably a bug in archange (maybe caused by the useage of high profile? just guessing), try mp4box too

peteag
12th May 2006, 20:12
mac version available? tried to makefile - nothing happend!