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 28th January 2006, 17:45   #41  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
Your video height is 354, so when you are displaying the video, you will want the width to be 2.35 times that (if you are convinced it is 2.40, do the same calculations just replacing 2.35 with 2.40)
So, display height = 354*2.35 = 831.9 = 832 (close enough)
Shouldn't this read Display Width = 354*2.35 =832 not Display Height?

Quote:
So, when displaying it, we want to stretch the 720 pixels of width we currently have to fill the size of 832 pixels. This is where the SAR signalling comes in. Basically, you can look at SAR as the amount to stretch the pixels horizontally. So, the SAR should be 832 / 720, or 832 : 720
Shouldn't this read 832:354? 720 was the original width not the height? Whenver I use MeGUI I've never had a SAR suggested where the width is greater than 720. When I Autocrop and then put the Width back to 720, MeGUI always has the SAR as 720:xx

Also I checked the log file and found the following in it.
Track 1 of 'D:\Projects\Red Eye\Red Eye.mkv': Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 844/352.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 29th January 2006, 00:35   #42  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
Shouldn't this read Display Width = 354*2.35 =832 not Display Height?
Yep, my bad.

Quote:
Shouldn't this read 832:354?
Nu-uh. Here's the simplest explanation as I see it, for SAR (which is DIFFERENT from DAR, PAR): SAR is really a fraction: SarX / SarY. The way the player treats this fraction is by multiplying it by the width (720) to get the display width. It leaves the height the same. If you think of it that way, you should see that my calculations are correct.

Quote:
720 was the original width not the height? Whenver I use MeGUI I've never had a SAR suggested where the width is greater than 720. When I Autocrop and then put the Width back to 720, MeGUI always has the SAR as 720:xx
Yeah, I've started looking at MeGUI's AR handling again, and it seems to be quite wrong. It is perfect when there is no cropping, but it has some quite serious bugs when there is cropping, which messes it all up. I've rewritten its algorithm, and I am testing it at the moment. It seems to be giving the same results as my manual calculations, so I'm testing now to see whether they look right when they play back.

Quote:
Also I checked the log file and found the following in it.
Track 1 of 'D:\Projects\Red Eye\Red Eye.mkv': Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 844/352.
I'm not sure where that is a log from, but it seems correct, by the sound of it.
berrinam is offline   Reply With Quote
Old 29th January 2006, 01:35   #43  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
I'm not sure where that is a log from, but it seems correct, by the sound of it.
That was the MeGUI log file which resulted from my encode using the parameters on the first page. So even though I entered in the SAR on the first page as indicated, the log file indicates the Aspect Ratio as per above.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 29th January 2006, 09:37   #44  |  Link
berrinam
Registered User
 
berrinam's Avatar
 
Join Date: Apr 2005
Posts: 1,740
Quote:
Originally Posted by DigitalDivide
That was the MeGUI log file which resulted from my encode using the parameters on the first page. So even though I entered in the SAR on the first page as indicated, the log file indicates the Aspect Ratio as per above.
Of course, the important question is 'does it work'? But other than that, I'll just say -- wow, magic; it works when I didn't expect it to. Most bugs tend to be the other way round
berrinam is offline   Reply With Quote
Old 29th January 2006, 10:14   #45  |  Link
iceborne
Registered User
 
iceborne's Avatar
 
Join Date: Aug 2003
Posts: 43
digitaldivide,
why is there a discrepancy between which display height you set. 354 or 352.
if its 352, then the sar given by megui (720/627) is the same ratio as 827*:720.

*calc -->352 height X 2.35 =827.

so i'm thinking there is nothing wrong with megui's sar suggestion. i've never ran into any ar bugs in all my encoding days

Last edited by iceborne; 29th January 2006 at 10:22.
iceborne is offline   Reply With Quote
Old 30th January 2006, 11:37   #46  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
As I already said, megui calculation of sar is (almost) useless since:
1.it confuses people with the input DAR (which should be 16/9 or 4/3 but instead it actually wants the output DAR (in DigitalDivide's case 2.35)), since rarely will be no cropping.
2.it doesn't actually help much since you already have to calculate DAR yourself so knowing the final resolution you have one extra calculation to make for the SAR (this is what actually megui does).
3.you're better off calculating the SAR or DAR yourself (SAR for input in the x264 config or DAR in mkvmerge).
__________________
zzz
Daodan is offline   Reply With Quote
Old 30th January 2006, 13:07   #47  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
I guess i need to install MeGui to see what it is doing, and tell doom9 to correct his gui. The reason is that the way you talk about DAR and SAR in this thread doesn't make any sense. For DAR you should have the choice between 1x1, 4x3 and 16x9. Other choices shouldn't exist. SAR or 'Sample Aspect Ratio' means PAR (at least when talking about AVC streams). Thus a selecting a SAR of 720xsomething when your final encoding should have a PAR of 1:1 doesn't make any sense.
Wilbert is offline   Reply With Quote
Old 30th January 2006, 13:35   #48  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Quote:
Originally Posted by Wilbert
I guess i need to install MeGui to see what it is doing, and tell doom9 to correct his gui. The reason is that the way you talk about DAR and SAR in this thread doesn't make any sense. For DAR you should have the choice between 1x1, 4x3 and 16x9. Other choices shouldn't exist. SAR or 'Sample Aspect Ratio' means PAR (at least when talking about AVC streams). Thus a selecting a SAR of 720xsomething when your final encoding should have a PAR of 1:1 doesn't make any sense.
Fisrt of all I'm gonna ulpoad a bit of an anamorphic encode of mine that has a DAR of 1.88 (1.88:1) so different than 16/9, 4/3, 1:1 (to playback correctly you must have enabled overlay mixer in both ffdshow and your player (mpc recommended)). The link:http://www.savefile.com/files/5028954
I don't understand why you say only those are possible dars? (it's about output not input, in case of input you are perfectly right). And who said that final PAR has to be 1:1? That's the whole point, no, of anamorphic, that the PAR is not 1:1.
__________________
zzz
Daodan is offline   Reply With Quote
Old 30th January 2006, 13:56   #49  |  Link
Doom9
clueless n00b
 
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
Quote:
Fisrt of all I'm gonna ulpoad a bit of an anamorphic encode of mine that has a DAR of 1.88 (1.88:1) so different than 16/9, 4/3, 1:1
Uh.. that does make no sense. DVD, DVB, ATSC and ISDB all know 4 DARs, the 3 Wilbert listed and another one nobody uses. What you're refering to is the aspect ratio of the movie.. there's no standard for that. DAR gives the aspect ratio of the playback device.. not the aspect ratio of the actual video.
The ITU people created a real mess with all these terms though. Basically if we had a horizontal stretch factor and that's it, things would be so much simpler. Leave it up to telephony people to create a mess in an area they should've never touched..
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org
Doom9 is offline   Reply With Quote
Old 30th January 2006, 14:10   #50  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Yes, you are perfectly right, that's what I've been struggling to say here. There is input (the original dvd) and output (the encoded movie). So the problem in your megui is that for input aspect ratio it actually wants the output one, and from here all the trouble people have understanding how it works. In my opinion this is how megui should work: you put input dar (usually 16/9), you use autocrop (or manual crop), and from that cropping megui should calculate that sar thing. However, megui leaves the same thing for sar no matter what you crop (because basically it requires from the beginning the desired dar). Ouf, I hope I made myself understood this time.
__________________
zzz
Daodan is offline   Reply With Quote
Old 30th January 2006, 14:25   #51  |  Link
Doom9
clueless n00b
 
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
it of course comes down to the question of how a playback device handles the DAR flag if the container has one. Is it h_res = v_res * dar ? If so, we need a formula that given the input resolution and dar, and output resolution, calculates the SAR. berrinam wrote the code so I'm not sure how that is being handled, and I have yet to come across a formula anywhere in this forum that would do just that (once again, I never looked at that particular code).
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org
Doom9 is offline   Reply With Quote
Old 30th January 2006, 15:00   #52  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Stupid me! I finally understood what was wrong and what needs to be changed in megui. Actually the SAR doesn't change however you crop, only the DAR is. So why my samples got wrong is because megui doesn't ask what dvd you have: PAL or NTSC, which is crucial. In case of NTSC it always is SAR 1.184 (so one should always put 118:100 in x264) and in case of PAL is always 142:100. That in case of aspect ratio of 16/9. In case of 4/3 is 107:100 for PAL and 88:100 for NTSC. I hope I didn't do any errors in my calculations.
So megui should ask for input DAR (olny 16/9 and 4/3 since I don't think there are original dvd's otherwise), type (PAL or NTSC) and suggest one of the values from above.
__________________
zzz

Last edited by Daodan; 30th January 2006 at 18:19.
Daodan is offline   Reply With Quote
Old 30th January 2006, 16:40   #53  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
@Doom9,
Quote:
it of course comes down to the question of how a playback device handles the DAR flag if the container has one. Is it h_res = v_res * dar ? If so, we need a formula that given the input resolution and dar, and output resolution, calculates the SAR.
The formulas for the PAR of pal/ntsc dvd:
http://www.doom9.org/index.html?/capture/par.html (16.2 examples 2 and 3). See also below:

@Daodan,
Quote:
And who said that final PAR has to be 1:1? That's the whole point, no, of anamorphic, that the PAR is not 1:1.
Correct, when the resulting encoding is anamorphic the output PAR (or SAR) is 1.778.

Quote:
Actually the SAR doesn't change however you crop
True!

Quote:
, only the DAR is.
No. You are still confused about DAR. DAR is only defined in certain containers like mpeg-2 (and not mpeg-4). MeGui should ask you whether your input is anamorphic or not, because that specifies the DAR of the input. If the stream is anamorphic the input DAR is 16x9, else it is 4x3. Whether it is PAL or NTSC can be read of from the input size (like 720x480), so you don't need to worry about that as a user. Given the input DAR and the source, the input PAR can be determined, thus for PAL (width: 720, height 576, DAR 4x3):

53.333 µs = 720 pixels /13.5 MHz
PAR = 576/720 * (4 / 3) * (53.333/52) = 1.094

PAL (width: 704, height 576, DAR 4x3):

52.148 = 704/13.5
PAR = 576/704 * (4 / 3) * (52.148/52) = 1.094

NTSC (width: 720 or 704; height 480, DAR 4x3):

PAR = 480/720 * (4 / 3) * (53.3333/52.6555) / (480/486) = 0.9116

NTSC (width: 704, height 480):
PAR = ... = 0.9116

etc ...

Last edited by Wilbert; 30th January 2006 at 16:43.
Wilbert is offline   Reply With Quote
Old 30th January 2006, 17:06   #54  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Well, the results are almost the same as mine (only I didn't take in consideration those µs). The only thing I didn't quite get is what is the deffinition of DAR, in my idea it was display aspect ratio so what I see, so in that case it doesn't matter if it's mpeg 2 or 4 or whatever. Thanks for the link of the guide, I missed that one.
__________________
zzz
Daodan is offline   Reply With Quote
Old 30th January 2006, 17:13   #55  |  Link
Doom9
clueless n00b
 
Join Date: Oct 2001
Location: somewhere over the rainbow
Posts: 10,579
@Wilbert: what I cannot find is how given a horizontal and vertical resolution and a PAR I get the playback resolution.. because in the end that's all the player has (especially a PC based player). And software DVD players work the same way... v_res * DAR = h_res.
__________________
For the web's most comprehensive collection of DVD backup guides go to www.doom9.org
Doom9 is offline   Reply With Quote
Old 30th January 2006, 18:00   #56  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Personally I prefer using the following equations: -

Code:
If you require your PAL encode to displayed at 1.33:1 (4:3), use: -
4     576     2304                    16
-  x  ---  =  ----  lowest dominator  --  or 16:15 (or 1.0666666)
3     720     2160                    15


If you require your PAL encode to displayed at 1.77:1 (16:9), use: -
16     576     9216                    64
--  x  ---  =  ----  lowest dominator  --  or 64:45 (or 1.4222222)
 9     720     6480                    45


If you require your PAL encode to displayed at 1.85:1 (37:20), use: -
37     576     21312                    37
--  x  ---  =  -----  lowest dominator  --  or 37:25 (or 1.48)
20     720     14400                    25


If you require your PAL encode to displayed at 2.35:1 (47:20), use: -
47     576     27072                    47
--  x  ---  =  -----  lowest dominator  --  or 47:25 (or 1.88)
20     720     14400                    25


If you require your PAL encode to displayed at 2.40:1 (12:5), use: -
12     576     6912                    48
--  x  ---  =  ----  lowest dominator  --  or 48:25 (or 1.92)
 5     720     3600                    25
The same principle can be applied to any MPEG-4 source by simply substituting the relevant horizontal and vertical resolution values


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |

Last edited by SeeMoreDigital; 30th January 2006 at 18:46.
SeeMoreDigital is online now   Reply With Quote
Old 30th January 2006, 18:01   #57  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
3 simple words..."I give up on anamorphic encodes"...
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 30th January 2006, 18:18   #58  |  Link
Daodan
unrecognized user
 
Join Date: Oct 2005
Location: home of Stella Artois
Posts: 303
Quote:
Originally Posted by DigitalDivide
3 simple words..."I give up on anamorphic encodes"...
Wise words, but not really 3. Ok, in an attempt to rescue you, i'll give you this method: when using 16/9 ntsc (usually your case, right?), delete any resizing in the avs and use 118:100 in the sar settings in x264 config in megui. Try samples from different movies and see if you are happy with this one. It should always work (in case the ntsc resolution is 720/480, not 704/480, which i think is rare).
__________________
zzz
Daodan is offline   Reply With Quote
Old 30th January 2006, 18:56   #59  |  Link
DigitalDivide
Registered User
 
Join Date: Jul 2005
Posts: 240
Quote:
Originally Posted by Daodan
Wise words, but not really 3. Ok, in an attempt to rescue you, i'll give you this method: when using 16/9 ntsc (usually your case, right?), delete any resizing in the avs and use 118:100 in the sar settings in x264 config in megui. Try samples from different movies and see if you are happy with this one. It should always work (in case the ntsc resolution is 720/480, not 704/480, which i think is rare).
I'll give it a try tonight.
__________________
Toronto,ON
DigitalDivide is offline   Reply With Quote
Old 30th January 2006, 19:17   #60  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally Posted by Daodan
when using 16/9 ntsc (usually your case, right?), delete any resizing in the avs and use 118:100 in the sar settings in x264 config in megui. Try samples from different movies and see if you are happy with this one. It should always work (in case the ntsc resolution is 720/480, not 704/480, which i think is rare).
118:100 can be simplified to 59:50 (which decimates to 1.18).

But you might want to give 32:27 (which decimates to 1.1851) a try too
__________________
| 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 online now   Reply With Quote
Reply

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 11:20.


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