PDA

View Full Version : [Megui] How can I get the correct aspect ratio


mat8035
19th September 2008, 23:07
Hi guys.

Firstly I appreciate that this topic has been discussed to death and I appologise for starting yet another thread on it. However I am having no luck after reading various guides and posts on this forum and it would be easier for me to start from scratch.

I am using the very latest version of MeGui and all it's updates. My source is PAL DVD 16:9 (720 x 576).. it is actually anamorphic with black bars top and bottom.

My avs script is simply cropping by 74 pixels top and bottom. (ignoring mod 16), making the the frame to encode 720 x 428. I am not doing resizing or anything else and I do not use MeGUI's Clever Anamorphic feature.

After reading a post on this forum, I append --sar 16:11 to my x264 script (because my source is 16:9 and I elect to use the mpeg4 standard for PAL 16:9) and check that this works by reading the encode log.

My finished encoded movie is stretched too wide in VLC player and MPC. Using Mediainfo to check the mp4 file it says that my AR is something like 2.4 or thereabouts. I have tried remuxing the video with YAMB and setting the AR myself but I have no luck.

Please could someone tell me where I am going wrong and what I need to do? From what I understand as I am using PAL 16:9 and not resizing, I should only need to use one of 3 AR's (ITU, mpeg4 and something else depending on preference) no matter how much I crop top and bottom. Using the Clever Anamorphic encoding produces similiar results with weird aspect ratios.

Thanks, Mat.

Avenger007
19th September 2008, 23:12
IIRC, --sar 64:45 is used for PAL 16:9.
Others are 8:9 for NTSC 4:3, 16:15 for PAL 4:3, 32:27 for NTSC 16:9.

poisondeathray
19th September 2008, 23:48
Those values only work if you don't crop, or resize to standard frame size

Frame Aspect Ratio x Pixel Aspect Ratio = Display Aspect Ratio
(In MeGUI, SAR is "Sample Aspect Ratio" which is the same as Pixel Aspect Ratio, I will use "SAR" from now on)
720/576 x 64/45 = 16/9 -> this is where the 64/45 comes from for -sar x:y values for PAL videos

Since you are cropping:
720/428 x SAR = 16/9
SAR = 1.0567901 by plugging it into a calculator

So you would use --sar 1.0567901:10000000, unless you can figure out the nice fraction (my math not so good)

This works for me (I don't use the script creator at all, or the anamorphic coding button, everything manually entered).

Option B: use a different MP4BOX build or MKVMERGE to specify the DAR in the container. I can confirm MP4BOX (0.4.5-dev_20070914) works, with the YAMB 2.0.0.8 GUI, or MKVMERGE 2.3.0

EDIT: If you are cropping should find out the TRUE value of the DAR from IMBD.com e.g. it might be 2.35 for that particular movie, then substitute that in for the 16/9 and solve for the SAR. If this was the case, it would be 1.3969444/10000000 for a 2.35 DAR film

Avenger007
20th September 2008, 00:59
Changing --sar to anything other than the original on the DVD would distort the image, i.e circles become ellipses. However, such distortions would probably be minor as long as the ratio isn't too far off.

mat8035
20th September 2008, 02:26
OK thanks for your help. It is a 2.35:1 film, cropping by 74 to 720 x 428 and using --sar 3600:5029 (1.3969444/10000000) as you suggested still gives me near enough the same result, it's stretched too much horizontally. What's going on?

Edit: However opening the file in MediaInfo tells me the aspect ratio is 2.35, which is correct. However MPC plays back the file as 1006 x 428 which I believe should really be 1024? (1024 / (428 + 74 + 74) = 1024 / 576 = 16:9)

poisondeathray
20th September 2008, 02:47
OK thanks for your help. It is a 2.35:1 film, cropping by 74 to 720 x 428 and using --sar 3600:5029 (1.3969444/10000000) as you suggested still gives me near enough the same result, it's stretched too much horizontally. What's going on?

Edit: However opening the file in MediaInfo tells me the aspect ratio is 2.35, which is correct. However MPC plays back the file as 1006 x 428 which I believe should really 1024? (1024 / (428 + 74 + 74) = 1024 / 576 = 16:9)


3600:5029 is wrong

720/428 x 3600/5029 does not equal 2.35

poisondeathray
20th September 2008, 03:00
Try avinaptic. It will give you the Display Aspect Ratio, Frame Aspect Ratio and Pixel Aspect Ratio.

An easy way in MeGUI that works for a 2.35 DAR (independent of cropping) is to use the global MeGUI_darx and global MeGUI_dary commands in your .avs script. This was broken a while ago, then fixed, then broken, but I think it's ok now. This will auto adjust the --sar to accomodate for your resize (i.e. it solves that linear equation, accounting for the changes in frame ratio)

global MeGUI_darx = 47
global MeGUI_dary = 20

Try it on a few frames, so you don't waste time. Just add Trim(0,100) to your script. Should take only a few seconds to encode.

Playback is also dependent on your player settings, filters, decoders - they all can change the way an encoded video looks by exhibiting different playback behaviour. Some will not honor the aspect ratio flags in the .mp4 container.

corporalgator
20th September 2008, 04:54
OK thanks for your help. It is a 2.35:1 film, cropping by 74 to 720 x 428 and using --sar 3600:5029 (1.3969444/10000000) as you suggested still gives me near enough the same result, it's stretched too much horizontally. What's going on?

Edit: However opening the file in MediaInfo tells me the aspect ratio is 2.35, which is correct. However MPC plays back the file as 1006 x 428 which I believe should really be 1024? (1024 / (428 + 74 + 74) = 1024 / 576 = 16:9)

The ratio of source is now 2.392523364485981308411214953271 to 1 which is 16/9*576/428 or 1024/428.

2.35 would be 1024/435.75 (roughly) You actually cropped off about 8 pixels of the movie if it truly was 2.35, but a lot of dvds are not.

mat8035
21st September 2008, 01:48
Try avinaptic. It will give you the Display Aspect Ratio, Frame Aspect Ratio and Pixel Aspect Ratio.

An easy way in MeGUI that works for a 2.35 DAR (independent of cropping) is to use the global MeGUI_darx and global MeGUI_dary commands in your .avs script. This was broken a while ago, then fixed, then broken, but I think it's ok now. This will auto adjust the --sar to accomodate for your resize (i.e. it solves that linear equation, accounting for the changes in frame ratio)

global MeGUI_darx = 47
global MeGUI_dary = 20

Try it on a few frames, so you don't waste time. Just add Trim(0,100) to your script. Should take only a few seconds to encode.

Playback is also dependent on your player settings, filters, decoders - they all can change the way an encoded video looks by exhibiting different playback behaviour. Some will not honor the aspect ratio flags in the .mp4 container.

This seems to work! Do you have any idea if the PS3 will honour the flags? Also just out of curiousity where did you get the 47:20 value from, and what would I use for *other* aspect ratios, however most DVDs seem to be 2.35:1

EDIT: No luck :( It was only correct in the AVS preview window with DAR 2.35, Mediainfo reports 1.39 or thereabouts and picture is stretched too much vertically in both VLC MPC.

poisondeathray
21st September 2008, 02:06
Yes I just tested the global MeGUI_darx and global MeGUI_dary , and it appears "broken" again or only works for non-cropped standard frame sizes.

The --sar x:y does work. I just tested it on a sample PAL DVD cropped using your values, and it would be the inverse (i.e. 5029:3600) if it was truely a DAR 2.35 film.

The media player playing back @ 1006x428 is correct - that is ~2.3504 DAR, but you particular DVD might not have been produced correctly to film studio specs.

But you can figure out your actual DAR (how it was encoded on your particular DVD) by taking a screenshot, opening in an image editor, cropping the borders and measuring the image size. (e.g. it might work out to be 2.33 or something on your particular DVD). Just enter that value into the equation and figure out the SAR.

mat8035
21st September 2008, 02:26
Yes I just tested the global MeGUI_darx and global MeGUI_dary , and it appears "broken" again or only works for non-cropped standard frame sizes.

The --sar x:y does work. I just tested it on a sample PAL DVD cropped using your values, and it would be the inverse (i.e. 5029:3600) if it was truely a DAR 2.35 film.

The media player playing back @ 1006x428 is correct - that is ~2.3504 DAR, but you particular DVD might not have been produced correctly to film studio specs.

But you can figure out your actual DAR (how it was encoded on your particular DVD) by taking a screenshot, opening in an image editor, cropping the borders and measuring the image size. (e.g. it might work out to be 2.33 or something on your particular DVD). Just enter that value into the equation and figure out the SAR.

Doing a screencapture and crop, it turns out 428 (actually 429 but the top row is half black/half picture, but lets call it 428) the same as the autocrop. So therefore should my my DAR should be 2.39, making my --sar 1.42?:1

poisondeathray
21st September 2008, 02:46
1024x418?? Your original vob is non-standard, or possibly your settings/filters in mpc are distorting playback. What happens when you play in mplayer,vlc or kmplayer?

if your original plays back 1024x418, what is the dimension of the screenshot of the vob cropped ? Assuming that is how you want the end product to look, that is the ratio you plug in for the assumed DAR (720/428 x SAR = assumed DAR) to figure out the SAR value you would enter

If you want, upload a small sample to a free hosting site (e.g. mediafire) and I'll have a look at it

BTW, using mod16, square pixels will enable proper aspect ratio playback virtually all software media players, not sure why you want to do it this way

mat8035
21st September 2008, 03:28
1024x418?? Your original vob is non-standard, or possibly your settings/filters in mpc are distorting playback. What happens when you play in mplayer,vlc or kmplayer?

if your original plays back 1024x418, what is the dimension of the screenshot of the vob cropped ? Assuming that is how you want the end product to look, that is the ratio you plug in for the assumed DAR (720/428 x SAR = assumed DAR) to figure out the SAR value you would enter

If you want, upload a small sample to a free hosting site (e.g. mediafire) and I'll have a look at it

BTW, using mod16, square pixels will enable proper aspect ratio playback virtually all software media players, not sure why you want to do it this way

Sorry, I confused myself with one of my encodes (it's late!) the original VOB plays back 1024 x 576, which is normal :) (I have edited my original post) Just to clarify the screencapture lets me confirm that the cropped frame of the source is 1024 x 428.

PS. are you suggesting that I overcrop to mod16? (720 x 416)

poisondeathray
21st September 2008, 03:51
Personally, I would crop and resize to mod16, using square pixels - this ensures maximum compatibility (but you still have to use proper settings e.g. if you are using PS3, use PS3 compatible profile to encode). It will be off by a bit, but not very noticeable e.g. 720x304 would be 2.368 - you can play with the values until it looks right.

If you want to stick with non-square pixels the converted fraction of 1.42:1 should work (--sar 17:12 should be close)

Sharc
21st September 2008, 11:45
Hi guys.

....After reading a post on this forum, I append --sar 16:11 to my x264 script (because my source is 16:9 and I elect to use the mpeg4 standard for PAL 16:9) and check that this works by reading the encode log.

My finished encoded movie is stretched too wide in VLC player and MPC.

--sar 16:11 should be fine for a PAL 16:9 DVD.
Did you set the player options in VLC or MPC correctly (default or standard - right click on the picture ....), otherwise your picture might get stretched twice.

mat8035
21st September 2008, 22:44
--sar 16:11 should be fine for a PAL 16:9 DVD.
Did you set the player options in VLC or MPC correctly (default or standard - right click on the picture ....), otherwise your picture might get stretched twice.

Yes using default aspect ratio in both. I thought that --sar 16:11 only works if you don't crop?

mat8035
21st September 2008, 22:59
Personally, I would crop and resize to mod16, using square pixels - this ensures maximum compatibility (but you still have to use proper settings e.g. if you are using PS3, use PS3 compatible profile to encode). It will be off by a bit, but not very noticeable e.g. 720x304 would be 2.368 - you can play with the values until it looks right.

If you want to stick with non-square pixels the converted fraction of 1.42:1 should work (--sar 17:12 should be close)

This is weird, 720 x 320 is the closest match (when using the AVS preview window and putting it over the source in VLC player) I don't get it!

Sharc
21st September 2008, 23:12
SAR is independent of any cropping you may choose. You could crop the picture to any shape, and the cropped picture will be played back undistorted, because the cropping does not affect the pixel aspect ratio, and the sar just tells the player how to stretch the cropped anamorphic picture. The stretching needs only compensate the anamorphic distortion of the original DVD picture which again is not affected by any cropping.

mat8035
22nd September 2008, 23:50
SAR is independent of any cropping you may choose. You could crop the picture to any shape, and the cropped picture will be played back undistorted, because the cropping does not affect the pixel aspect ratio, and the sar just tells the player how to stretch the cropped anamorphic picture. The stretching needs only compensate the anamorphic distortion of the original DVD picture which again is not affected by any cropping.

Have you tested this on a 16:9 PAL anamorphic dvd? It don't work for me.. :(

poisondeathray
23rd September 2008, 00:48
--sar 64:45

Your display area of the original .vob is 1024x576 - when cropped the area of the intendend goal = 1024x428, this gives you a DAR of 2.39252 as coporalgator said earlier

You cropped to frame size of 720x428

GOAL of your DAR = Frame Aspect Ratio x Pixel Aspect Ratio (i.e. --SAR in MeGUI)

1024/428 = 720/428 x SAR

SAR = 64/45 as Avenger007 mentioned earlier (or 1.4222222...)

mat8035
23rd September 2008, 16:03
--sar 64:45

Your display area of the original .vob is 1024x576 - when cropped the area of the intendend goal = 1024x428, this gives you a DAR of 2.39252 as coporalgator said earlier

You cropped to frame size of 720x428

GOAL of your DAR = Frame Aspect Ratio x Pixel Aspect Ratio (i.e. --SAR in MeGUI)

1024/428 = 720/428 x SAR

SAR = 64/45 as Avenger007 mentioned earlier (or 1.4222222...)

Nice one! Cheers for the help everyone. Displays in MPC as 1024 x 428 and the image seems to look fine, so I'm guessing it worked fine! Have wacked the formula into Excel so should be able to use it for other crop sizes.:thanks:

Avenger007
24th September 2008, 19:23
Quoted for truth from the H.264 specification:
sample aspect ratio: Specifies, for assisting the display process, which is not specified in this Recommendation | International Standard, the ratio between the intended horizontal distance between the columns and the intended vertical distance between the rows of the luma sample array in a frame. Sample aspect ratio is expressed as h:v, where h is horizontal width and v is vertical height (in arbitrary units of spatial distance).

mat8035
8th October 2008, 17:48
It's all working fine with --sar 64:45 but how much of a problem (if any) is it to encode to x264 with a non-mod16 height? e.g. in my example 720x428 The video plays back perfectly on my PS3.

Avenger007
8th October 2008, 17:54
No problem that I know of.

mat8035
30th November 2008, 16:17
I thought that quality suffers? As I am using the PS3 profile which has a max bitrate of 1000.

Anacletus
1st December 2008, 11:11
You can change the birtrate, since the PS3 doesn't have that kind of limit of 1000 Kbits..