View Full Version : Changed Aspect Ratio after encoding
antineff
23rd March 2009, 11:45
Hi Folks,
I have a problem which has probably to do with some avisynth settings, but since I'm not too familiar with all that video stuff, I do not know where to "turn the knobs" to achieve the wanted results:
The test-environment:
I recorded a part of the CloneWars Series via DVB-T, so I got an MPEG2-Stream, which was, as GSpot stated DVD-compatible.
Using any player it is displayed in 16:9 although the original format is 5:4.
http://www.neffneff.de/doom9/GSpot-o.jpg
When I do the easy way using XMediaRecode, I receive a fine result, keeping the correct aspect ratio, as stated in GSpots d-section under "dar":
http://www.neffneff.de/doom9/GSpot-x.jpg
Trying to get a similar result using MeGUI, which was called a "professional" tool by the german Magazine CHIP (maybe because you have to mess around with some avisynth-options) I have no chance to get the "recommended display size" to an aspect ratio of 16:9, which results in ugly eggheads:
http://www.neffneff.de/doom9/GSpot-m.jpg
My question: How can I manage to choose the recommended display size or, should I use a different tool to have more influence on the encoding results or, how do I get a highly compressed h.264 file combined with an aac-he audio stream (since XMediaRecode doesn't support that)?
Thank you very much!
J_Darnley
23rd March 2009, 14:16
Either resize the video when you encode it or set the aspect ratio information. MeGUI supports both. I though it did detect anamorphic video but you can easily force it in its script creator which is also where you can choose to have anamorphic video or not. If you are encoding it manually, add a resize instruction to the avisynth script or set the aspect ratio when encoding (--sar width:height Specify Sample Aspect Ratio) or when muxing (you will have to lookup how you do it with mp4box).
Inspector.Gadget
23rd March 2009, 15:16
If you use "Smart Anamorphic Encoding" in the AVS Script Creator, MeGUI will pass this as a muxing flag to the MP4 and MKV muxers. Simply set that to "Pal 16:9", select "Overcrop to mod16" and don't apply any cropping unless you need to.
antineff
23rd March 2009, 15:49
I'm not sure if I understand that right, but I believe resizig is not the same as that what XMediaRecode did. Also I believe it is not the thing to change the sar-value but the dar-value (I do not really know, what that is so maybe I'm talking rubbish). As you can see in all three GSpot analyses the sar is set to 5:4 while the dar differs and should be 16:9 as a correct result like it is in the XMediaRecode output and with the original mpeg.
BTW: If you or someone else finds a solution, can you please explain how to do it (with MeGUI?)! Thank you anyway!
antineff
23rd March 2009, 16:09
@Inspector.Gadget: Well, it seems, that comes much closer to the solution. But the aspect ratio value in dar is now 20:11. Do you know how that is?
poisondeathray
23rd March 2009, 16:22
If you want it exactly like the original anamorphic encode, no cropping, use --sar x:y as J_Darnley said.
The value for a PAL 16:9 would be 64:45, because:
Display Aspect Ratio = Frame Aspect Ratio x Sample Aspect Ratio
FAR is just the width:height of the frame size
SAR is can be thought as the called pixel aspect ratio or the w:h of pixels
16/9 = 720/576 x 64/45
So enter --sar 64:45 in the command line box in the encoding options ; if you don't enter the value x264 assumes 1:1 hence the skewed aspect ratio
Most, but not all players will accept anamorphic signaling at the stream level
Option 2 is to use container signalling e.g. in mkvmerge or mp4box. So you just re-package the video and set the DAR (for mkv) or SAR (for mp4 box). It tells the player to "stretch" on playback. Most but not all players accept the container aspect signalling
Option 3 is to resize and use 1:1 pixels. The aspect maybe a bit off e.g. it might be 1.75 instead of 16/9 , but 100% of players will accept this.
2Bdecided
23rd March 2009, 17:12
Option 3 doesn't have to be "a bit off" - there are plenty of exact 16x9 resolutions, e.g. 1024x576, 640x360, etc etc.
As for which option is preferable - it depends what you are going to do with your x264 video.
Cheers,
David.
antineff
23rd March 2009, 20:36
@ poisondeathray: Wow, the first option works very well as the aspect ratio is correct now. Although I did not reaqlly understand what sar is and how it comes to those values.
I guess I will wait testing the other options unless I decide to study video-container techniques. :)
Now I still have a problem with pale colours, but I will use another threat for that, maybe tomorrow.
Thanks a lot, guys!!!
kemuri-_9
23rd March 2009, 21:05
@ poisondeathray: Wow, the first option works very well as the aspect ratio is correct now. Although I did not reaqlly understand what sar is and how it comes to those values.
basically the Sample AR is the pixel stretch/crunch to get your pixel AR become the Display AR
SAR = (Desired DAR) / (PAR)
= (16 / 9) / (5 / 4)
= 64/45
-> every 45 encoded horizontal pixels stretch out to 64 on display.
antineff
23rd March 2009, 22:29
@kemuri-_9: Ah, thanks for the explanation! I think I got it right now! Thank you very much!
Wilbert
23rd March 2009, 23:10
basically the Sample AR is the pixel stretch/crunch to get your pixel AR become the Display AR
SAR = (Desired DAR) / (PAR)
= (16 / 9) / (5 / 4)
= 64/45
No, it's not. SAR is the reciprocal of PAR.
antineff
24th March 2009, 12:01
Thanks for the confusion, Wilbert. :)
If I remember my arithmetic lessons correctly that would mean that if par is 5:4 the reciprocal of it is 4:5 which is much different to 64:45 and would result in a strange aspect ratio.
Alex_ander
24th March 2009, 14:15
Once again that useless invention called PAR causes misunderstanding and errors. All you need for correct resizing is to know in what proportion (DAR) the number of pixels stored in your image file should be shown. In case of DVD mpeg there are just 2 versions of DAR (4:3 and 16:9) and a separate (and completely independent) 1-bit parameter is used in mpeg headers to tell the player which of the 2 ways should it display the pixels stored in file*. Your target file type or display device not necessarily will support this type of setting DAR. Most avi files are displayed in proportions determined by horizontal/vertical pixel numbers, so if you select target pixel numbers in 16:9 ratio (e.g. 1024x576) and resize what you have (720x576) to those planned numbers, most devices will show video in correct AR.
*standards of digitizing analog video (also followed by DVD makers) want a slight correction: not 720 but 704 ( exactly 702 for PAL) horizontal pixels correspond to edge of a 4:3 or 16:9 image, e.g. you can crop the source DVD file to 704 before resizing (usually there are just black borders).
antineff
26th March 2009, 13:30
Well yes, I believe that a "hard reformat" which you do with a "real" resize would result in something that will be displayed in the correct AR by every player. But: I also believe that recalculating a picture, especially when making it bigger, may lead to some kind of distortion which is firmly written to the resulting file. I guess that if only the player ist told how to display the picture it belongs to the player and not to the data how far the visible result is distorted.
Or am I on the wrong track?
Alex_ander
26th March 2009, 16:58
In case you are planning to watch those files on PC only, there are good chances to avoid resizing and just set DAR (if your encoding software doesn't support it, there are utilities like mpeg4modifier for doing it after). As for hardware players, there are mandatory things for those (following DAR flags for DVD mpeg files) and optional things (following AR flags in files like avi). It is possible to use DAR setting in avi file, but this will give very limited compatibility with existing players. For example there's divx standard established by divx owners (picture resolution like on DVD + setting DAR to 4:3 or 16:9), but it only works in so-called divx-ultra certified DVD players, most other ones will show a 720x576 divx file with 16:9 flag in 5:4 proportion. That is because DAR flags originally weren't a part of older avi standards. Traditionally such files were made assuming display proportions from pixel numbers ratio. Now this is often called 'square pixels' to distinguish from the other type of setting DAR (some people imagine rectangular 'non-square' bricks in case of DVD etc). Unfortunately, this therminology developed itself into 'pixel aspect ratio' (PAR) calculation concept using brick analogy. Those unnecessarily introduced values (derived from other known numbers) either bring to easily made mistakes, or are simply reduced if used correctly in calculations. You will find 'PAR' e.g. in a lot of formulas for calculating lettrboxed image sizes but if you ever need it, I'd advice to use your skill in simple arithmetics instead.
SeeMoreDigital
26th March 2009, 19:13
Hi antineff,
Maybe you will find my old Aspect Ratio Signalling Calculator (http://forum.doom9.org/showthread.php?t=107039) useful?
It requires Microsoft .NET to run ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.