PDA

View Full Version : Cropping - what do I do wrong?


Octo-puss
31st August 2008, 19:25
I was about to encode something when I realized I could crop the big black bars on top and bottom and make the result a bit smaller. It worked, but it plays in wrong aspect ratio - it's vertically stretched to the whole screen. Maybe I don't understand the whole thing correctly, but I thought it's possible to crop black space and still have same image as the original, only that the black space will be put there during playback by the player. So how is it? I hope I make any sense..

nurbs
31st August 2008, 20:02
You need to pass the correct aspect ratio to the encoder. I'm not good at this myself, but I think croping also changes the SAR you have to pass to it. MeGUI offers the "Clever anamorphic encoding" option in its avs creator to take care of that. I'm sure other GUIs offer similar options as well.

Octo-puss
31st August 2008, 20:08
I tried that and it still looks weird :(

Sharc
31st August 2008, 20:13
If you select the SAR according to the recommendations I made in your other post(s)/threat(s), everything should playback correctly. The nice thing about SAR is that īt works independent of any cropping, and you don't have to do any calculations.
Make sure that you do not resize (resizing will affect the SAR), just crop the borders and leave the rest. And make sure that your playback device is set correctly, ie using the SAR of the encoded file and not doing it's own stretching.
What is your playback device? PC (like MPC) or Standalone player? Is your source NTSC or PAL? 3:4 or 16:9? Which encoder are you using? x264 or Xvid? Is your source an anamorphic DVD or something? Can you post a screenshot of an uncropped original frame?

nurbs
31st August 2008, 20:13
I think there is a bug in MeGUI that passes too large SAR values to the encoder under certain circumstances. Not sure if that is already fixed.

Octo-puss
31st August 2008, 20:23
That's what I did - crop top and bottom and pass --sar 64:45 to x264 in the presets dialogue. And the resulting video is vertically stretched to the whole screen.
The source says 720x576 16:9 and Megui says PAL.
Playing from MPC.

I got no idea how to tell whether source is anamorphic or not. I gave up on this whole thing because there is no way I'd ever understand it (the more guides I read the less I understand).

Octo-puss
31st August 2008, 20:45
Aha, according to screenshots from original and encoded versions it's ok, but MPC shouldn't stretch the encoded one. In the properties I can see:
Video: MPEG4 Video (H264) 720x424 (128:53) 25.00fps [Video]

The AR is obviously wrong. Apparently it's either a bug or the --sar doesn't work that independantly...

Sharc
31st August 2008, 20:49
I assume the DVD is anamorphic.

Check the following in MPC
- Start the playback in MPC
- Right click on the picture
- Video Frame =>
Tick "Touch Window from inside"
Tick "Keep Aspect Ratio"
==> Override Aspect Ratio => Select "Default"

Octo-puss
31st August 2008, 20:55
==> Override Aspect Ratio => Select "Default"

Omg. I feel like an idiot now.
So much for forgetting to look at the settings... I know I was digging in this part of them few weeks ago.. Obviously I left something overlooked.

Jeez...

edit: btw, the independancy of sar applies to cropping in all directions?

poisondeathray
31st August 2008, 21:12
Isn't the easiest way just to use

global MeGUI_darx = X
global MeGUI_dary = Y

It seems to work ok in the latest MeGUI (it was b0rked in a few versions), but the benefit is that it will autocalculate everything based on final resize. So even if you crop, resize, whatever, it ends up ok

My understanding is that:
Display Aspect Ratio = Frame Aspect Ratio x Pixel Aspect Ratio

FAR is the frame dimension ratio, e.g. 640/480 = 1.33333
PAR is the pixel ratio, e.g so square pixels 1/1 =1.0000

I think MeGUI_darx = X, MeGUI_dary = Y business in the .avs script for MeGUI auto calculates and adjusts the PAR to fit the resized frame, therefore you end up with the correct DAR, at least theoretically (Maybe Sharktooth can clarify the programming mechanics)

(The "SAR" used in megui is defined as the Sample Aspect Ratio. I think the "SAR" used in MeGUI nomenclature is actually the PAR, pixel aspect ratio, which is the width:height ratio of a pixel (not frame) http://mewiki.project357.com/wiki/Glossary#SAR). This is not to be confused with the "other SAR" which is supposed to mean the Storage Aspect Ratio, which is actually the Frame Aspect Ratio in the equation above. The terminology is a bit twisted. If you go by the equation above, the names make sense for what they actually do.

If you use ONLY the --SAR X:Y in the command line, this will adjust the Pixel Aspect Ratio independent of the Frame Aspect Ratio. So unless you have a square 1:1 frame dimension (e.g. 300x300 frame), you have to compensate for both in the calculation (i.e. the --SAR X:Y values would be the ratio required to make the DAR what you want, for a given resized Frame Aspect Ratio) - hence if you memorize those values Sharc gave it would work for those exact frame size dimensions (you can confirm with a calculator and several test encodes)

So I think the easiest way is not to touch the --SAR X:Y, but to use the global_MeGUI_darx = X, global_MeGUI_dary = Y business, since it works for every frame size. If you are good at math, you can use the --SAR X:Y and it should give you the same thing (just plug in the FAR into the equation, the desired DAR, and the answer is your SAR value)

I could be wrong, but it seems to work and is much easier than memorizing or calculating ratios (but it's really the same thing)

Sharc
31st August 2008, 21:36
btw, the independancy of sar applies to cropping in all directions?
Yes, crop however you like: left top, right, bottom, even into the active picture ("overcropping").
The sar represents the width:hight of a single pixel of the original picture. It is not affected by any cropping.

Nestor Fish
31st August 2008, 23:09
MPEG suggested values:
Non anam. 16:9 Anamorph
PAL 12:11 16:11
NTSC 10:11 40:33

based on ITU-R BT.601:
Non anam. 16:9 Anamorph
PAL 128:117 512:351
NTSC 4320:4739 5760:4739


Where does your 64:45 come from?

Octo-puss
31st August 2008, 23:23
No idea. Found some numbers here on forums.

Nestor Fish
31st August 2008, 23:26
OK, I got it: 16/11*704/720.
It should be used with care, since it applies to wrongly mastered, non-ITU DVDs. BTW a standalone DVD player will never use this SAR, but one of tables.

Octo-puss
31st August 2008, 23:35
Uhm... What kind of twisted math is that? :)

What do you mean by wrongly mastered DVDs? And what does the ITU abbreviation mean anyway? It's been confusing me a little in past as well.
I've been using this value since ever and it produces exactly same image as the source, which is good enough for a person who doesn't understand how all these things around video work :)
Oh and I neither own nor use a standalone player. It's my PC all the way.

Nestor Fish
1st September 2008, 00:17
Uhm... What kind of twisted math is that?
Figures come from: A Quick Guide to Digital Video Resolution and Aspect Ratio Conversions (http://lipas.uwasa.fi/~f76998/video/conversion/)
And extensions from MPEG-4 (704 for width).

What do you mean by wrongly mastered DVDs? And what does the ITU abbreviation mean anyway?
Active image (the one you have on your tv with a "true" player) is not exactly the one encoded in MPEG2 on DVD. You must crop horizontally to get the real active 4/3 or 16/9 frame. See the link above.
ITU-R: International Telecommunication Union - Radiocommunication Sector (http://www.itu.int/ITU-R/index.asp?category=information&rlink=rhome&lang=en) Their BT.601 (http://en.wikipedia.org/wiki/BT.601) standard is the one used for digital video encoding, like in DVDs.
It's been confusing me a little in past as well.
Quite the same for me. It took me a few days to discard wrong values encountered here and there.
I've been using this value since ever and it produces exactly same image as the source, which is good enough for a person who doesn't understand how all these things around video work
It depends on what you name "same image as the source"...
Oh and I neither own nor use a standalone player. It's my PC all the way.
An example of correct DVD SAR handling is the current developed VLC (0.9.0). In my memory, the current stable is forked: it outputs the whole frame as 4/3 or 16/9, while it is in fact 4/3*720/702=480/351 or 16/9*720/702=640/351 (for PAL). I used to enter custom aspect ratios to compensate this.

Octo-puss
1st September 2008, 00:35
The way I "test" it is to play a DVD and then its encode in new window and compare the size (encode put over the original), lol. Stuff encoded with this sar matches the original image perfectly.
I was curious though and tried this 512:351. Looked weird, and I mean the image, not only the size.

Nestor Fish
1st September 2008, 00:47
The way I "test" it is to play a DVD and then its encode in new window and compare the size (encode put over the original), lol. Stuff encoded with this sar matches the original image perfectly.
Do it with VLC 0.9.0 (http://nightlies.videolan.org/).
I was curious though and tried this 512:351. Looked weird, and I mean the image, not only the size.
Interesting, could you post a screenshot?

Sharc
1st September 2008, 07:40
Just a footnote: The ITU-R and the mpeg-4 sar ratios match very closely, for example 16:11(mpeg-4)=1.454545... whereas 512:351(ITU-R)=1,45869 for a PAL 16:9 DVD.
I always use the mpeg-4 values, because AFAIK some encoders don't handle the large numbers of the "exact" ITU-T x:y values properly. With the mpeg-4 values one is on the safe side, even though there might remain a slight - hardly noticeable - AR error compared to how the original DVD has been mastered.

setarip_old
1st September 2008, 08:06
@Octo-pussI was curious though and tried this 512:351. Looked weird, and I mean the image, not only the size.You might want to change that to 512:352, so that everything is mod16...

Octo-puss
1st September 2008, 09:44
Do it with VLC 0.9.0 (http://nightlies.videolan.org/).

Interesting, could you post a screenshot?

Well, screenshot taken from original is 1024x576 whereas the encode is 1050x576. Cant post now, gotta rush.

edit: same in VLC. Encoded part of the video is horizontally bigger and otherwise have different AR from original.

Nestor Fish
1st September 2008, 17:27
@Octo-pussYou might want to change that to 512:352, so that everything is mod16...
That's MPEG specs 16:11. :p

Nestor Fish
1st September 2008, 17:37
Well, screenshot taken from original is 1024x576 whereas the encode is 1050x576. Cant post now, gotta rush.

edit: same in VLC. Encoded part of the video is horizontally bigger and otherwise have different AR from original.

It due to what I attempted to explain... Misinterpreting standards gives you 1024x576 (the 720x576 whole frame considered as 16/9), which is simply wrong and compress horizontally your image. Considering the 702x576 as the real 16/9 image (which should be the case, and is, with pro video equipment !) will give 1050 width (your 1024 x 720 / 702) to respect original aspect if you encode full width.
BTW, by encoding full width, you end up with blurred edges, which wouldn't be visible with standard output (say 8 cropping on each edge, although some are shifted, eg. 4 - 12).

Nestor Fish
1st September 2008, 17:43
Oh, I forgot... What output resolution VLC 0.9.0 gives you on original DVD ? (not from vobs, but opening DVD from your drive : Media -> Open Disc -> DVD)

Nestor Fish
1st September 2008, 17:53
Just a footnote: The ITU-R and the mpeg-4 sar ratios match very closely, for example 16:11(mpeg-4)=1.454545... whereas 512:351(ITU-R)=1,45869 for a PAL 16:9 DVD.
I always use the mpeg-4 values, because AFAIK some encoders don't handle the large numbers of the "exact" ITU-T x:y values properly. With the mpeg-4 values one is on the safe side, even though there might remain a slight - hardly noticeable - AR error compared to how the original DVD has been mastered.

I do the same here., It results in far fairer output resolutions for mkv container for example... Error will be 0.284% PAL, 0.274% NTSC, simply unnoticeable. By cons, you have around 2.5% with the standard violation, which is obvious. The point is knowing that truth lies in standard... :devil:

SeeMoreDigital
1st September 2008, 19:13
It due to what I attempted to explain... Misinterpreting standards gives you 1024x576 (the 720x576 whole frame considered as 16/9), which is simply wrong and compress horizontally your image. Considering the 702x576 as the real 16/9 image (which should be the case, and is, with pro video equipment !) will give 1050 width (your 1024 x 720 / 702) to respect original aspect if you encode full width.Hi Nestor Fish,

Just in-case you were not aware.... There's not a single software media player that respects the ITU specs.

Meaning all commercially produced PAL (720x576) 4:3 or 16:9 DVD's will be displayed at 768x576 or 1024x576 pixels respectively. And all commercially produced NTSC (720x480) 4:3 or 16:9 DVD's will be displayed at 640x480 or 853x480 pixels respectively!

Nestor Fish
1st September 2008, 19:20
I wrote that latest VLC will.

Edit: I just tested 0.9.1, it it does not correct AR... Pfff.