PDA

View Full Version : megui and overiding "clever anamorphic" settings


cablemonkey
31st January 2008, 06:25
I recently began backing up my DVD collection due to the acquisition of a NMT hardware media player, and am currently working on using MeGUI to do x264 conversions. After doing my research, i've just about got quality to where i want it, but i'd been struggling with getting anamorphic encodes to come out right. I think i finally worked out the answer last night, and my test encodes finally have the same AR on my SD TV as a straight DVD rip, but i'm still a little puzzled as i only got it to work by manually overiding the "hints" produced by MeGUIs "clever anamorphic" option.

I'm starting with 2.35:1 (really 2.39:1) 16:9 anamorphic encoded DVDs. I'm checking the anamorphic option and overcropping to 720x352 (mod 16), but the AR never seemed to come out right, always maybe 10% off. To test, i'd flip between watching the actual DVD on my SD tv and the x264 encode (using some tape for marking the position of on screen referrence points). I know that because of the overcrop i'd lose a few lines and have slightly larger letterbxoing, but the objects in the frame should have the same position.

Reading some great posts here (and elsewhere), i worked out the following:

SAR * PAR = DAR, so:

720/480 * x/y = 16/9 ie
3/2 * x/y = 16/9 and so
x/y = 16/9 * 2/3 = 32/27

so PAR should be 32/27 on all 16:9 anamorphic NTSC DVDs

So long as i only crop and don't resize, PAR should be constant, so flipping the equation around to get the correct DAR with my newly cropped video i get:

720/352 * 32/27 = x/y ie
45/22 * 32/27 = 1440/594 = 80/33

So my end DAR for a 720/352 cropped 16:9 DVD should be 80/33. If i go back and edit the avisynth script produced by MeGUI and update the script to show:

MeGUI_darx = 80
MeGUI_dary = 33

and then encode, the AR turns out (visually) perfect to my eyes, aided with visual markers (though avinaptic does show minor differences, which i'll mention coming up). This also seems to say that so long as my source is a 2.35:1 anamorphic DVD, i'll generally always be overcropping to 720/352 and my DAR will always be 80/33, which will make things easier.

What i don't understand is:

1) Why when i use anamorphic and overcrop for mod-16 in the script creator, is megui setting the DAR hints as 3107/1250 and not 80/33?

2) even with MeGUI using my revised dar hints, it sets the DAR in the end mkv to 2133/880. Since 80/33 = 2.4242... and 2133/880 = 2.42386..., its close enough that i'm not noticing a difference. But why the change?

Is there something obvious i'm missing?

cablemonkey
31st January 2008, 15:49
Well, i found my own answer to question #1, digging through the MeGUI src. I guess MeGUI (or rather the avisynth script creation tool) constrains its anamorphic encodes to a limitted set of "standard" aspect ratios, specifically:

1.0, 1.33333, 1.66666, 1.77778, 1.85, 2.35

Rather than give you the exact DAR, it feeds it through a constraining function called getAspectRatio(), which finds the "closest acceptable fit" within the above subset of options.

I'd say that it would be nice if this was optional, but since you can manually overide the suggested DAR in the edit window, i guess it doesn't matter. I'm guessing that the override of the DAR noted in the second question somehow relates to the use of this function as well, later in the process.

Honeyko
1st February 2008, 01:17
I'm starting with 2.35:1 (really 2.39:1) 16:9 anamorphic encoded DVDs. I'm checking the anamorphic option and overcropping to 720x352Take a screen-clip of the movie in VLC; if the screen width is 853 (typical with NTSC), then, provided all you're doing is cropping, and there's no resizing of vertical height, then your PAR is 720x352 and DAR is 853x352.

Mind you, odd numbers round up -- so if your top and bottom numbers are both odd, you're picture's actual cropped height will be 350 and not 352 (and this can be confirmed by encoded a tiny clip with no re-sizer).

cablemonkey
1st February 2008, 02:20
Take a screen-clip of the movie in VLC; if the screen width is 853 (typical with NTSC), then, provided all you're doing is cropping, and there's no resizing of vertical height, then your PAR is 720x352 and DAR is 853x352.

So long as im cropping to 720x352 (which i prob will be for all 2:39 movies), 80/33 should work great. That is a convenient shortcut for doing DAR though, eliminates a lot of the math and is off by < 1 pixel. Thanks! I do think you meant SAR is 720x352, not PAR though.

Honeyko
1st February 2008, 02:49
So long as im cropping to 720x352 (which i prob will be for all 2:39 movies), 80/33 should work great.You can't assume that. Examining screen-clips is always necessary, because DVD AR is not always the same as theater AR. Some DVDs play at 853 wide, others at 1024.That is a convenient shortcut for doing DAR though, eliminates a lot of the math and is off by < 1 pixel.I don't use MeGUI, so maybe this is a dumb question -- but are you permitted to choose exact width and height for your anamorphic DAR?Thanks! I do think you meant SAR is 720x352, not PAR though.Well, if there are 720x352 pixels in the output, that's PAR. The source is 720x480 letterboxed (I am presuming).

cablemonkey
1st February 2008, 06:45
OK, after some more research, it looks like the answer was right in front of me the whole time:

http://forum.doom9.org/showthread.php?p=239924

My calculations were all based on 16:9 really being 16:9 (1.778), not ITU 16:9 (really 1.823). Of course, as the script creator tool shows it clearly uses ITU 16:9, i feel a little silly now. Just to test, if i set a custom input DAR to 1.778, and overcrop to mod16, the output DAR hints come out as expected (insignificant deviation from my tested 80/33 DAR). So, i wonder if that means my Popcorn Hour is scaling to true 16:9 and not ITU 16:9 on playback, hence the different visual AR from the DVD source? More testing, oh joy... my head already hurts. Thank god fixing DARs just requires a remux and not a re-encode.

Ever get the feeling this (http://www.despair.com/mis24x30prin.html) may be you?

Honeyko
4th February 2008, 06:28
My calculations were all based on 16:9 really being 16:9....Never do that. -- Get used to counting pixels, and all will be right in your universe. Never futz with fractions (less than whole pixel counts) ever again.

Honeyko's down-n-dirty anamorphic DVD rip guide (for XviD/AVI, because it requires slightly more work than x264, which muxes anamorphic in MKV or MP4 containers) for a typical horizontally-stretched anamorphic film:

1. Screen-clip source video in both MPC and VLC. (Take several clips at various points during the film, because sometimes certain scenes will need a pixel or two more cropping than others. Generally the difference isn't more than one or two, so just crop to the most heavily black-barred scene in the film. Films with severely disjointed black-barring can be restreamed into pieces with VideoRedoPlus, encoded separately and resized to the same dimensions, then rejoined later.)

2. Examine anamorphic-stretched VLC clip, and count the pixel height and width of the "good" part of the image. A very good tool for such examination is ImageReady, a pre-prep tool included with Adobe Photoshop; old versions work nicely (I'm using version 3). In ImageReady, you can zoom in until individual pixels are gigantic. With the rectangle tool, just drag a rectangle, Ctrl-C, then Ctrl-N (for new), and it'll create a new window with the exact dimensions of your clip-in-memory...thereby giving you numbers to write down for later.

3. Compute crop values from MPC's "squashed" clip, and round up to even numbers (because your encoder will either crash, or do it automatically anyway). Count the pixel width and height of the "kept" imagery.

Let's say your source is a typical 720x480 NTSC DVD, and VLC's DAR is 853x480 (with letterboxing and a scummy left edge), while MPC's post-crop & rounded-up "good" imagery is 718x460 after top and bottom black bars, and two pixels on the far left are cropped. This means output DAR is actually 851x460 (850.963 = 853.333 x 718/720)...and a rectangle clip of the "good" part of a VLC clip in ImageViewer should confirm this to within a pixel.

4. Encode at 718x460 with no encoder resizing, or 720x464 if you want a MOD16 encode.

5. Open the finished output file in MPEG4Modifier (this is the "slightly more work than x264" part), and adjust DAR to 851x460 if there was no encoder resizing, or 858x464 for the MOD16 encode (858.36 = 850.963 x 464/460).

6. Open that finished restreamed video in AVImuxGUI for the final mux of all video, audio and subtitles (if any).

Joila! Piece-a-cake.

What makes this all work is getting proper width and height pixel counts from your VLC and MPC screen-clips.