Log in

View Full Version : Help me understand "clever anamorphic" and DAR in MeGui


psychohobbit
5th May 2008, 22:23
OK, I've come to the conclusion that I'm an idiot -- because I just can NOT figure out how to properly convert DVD MPEG2 video to MP4/X264 using MeGUI in "clever anamorphic" mode. As near as I can tell, certain things simply do not work at all, and that surely cannot be right -- so please, can someone help me make sense of this?

I'll use an example to illustrate what I'm doing, as well as my thought process. Here we go...

I'm backing up my DVD of the movie "Legally Blonde". I rip the DVD using DVD Decrypter in IFO mode, extracting and demuxing the video and audio streams as well as the chapter information. For now, I only worry about the video portion.

I now have a file called VTS_09_1 - 0xE0 - Video - MPEG-2 - 720x480 (NTSC) - 16~9 - Letterboxed.m2v. MediaInfo says it's MPEG2, 720x480 with a display aspect ratio of 16/9. So far, so good.

From MeGUI, I take that file and create a .d2v file. I open the .d2v file from MeGUI, and it launches the AVS script creator and video preview window. I notice that the video is strethced vertically, which I figure is normal since the DVD is encoded anamorphically.

This movie has an aspect ratio of 2.35:1, more or less, so even at 16x9 I have black bars above and below the video. To fix this, I use MeGUI's "Auto Crop" feature, and it suggests cropping 54 pixels above and 58 below. Looks reasonable enough, no more letterboxing in the preview window. Since I started at 720x480, my video size is now 720x368. Viewed with those dimensions, the video is still stretched, which makes sense since all I've done is crop the top and bottom.

Now, I guess the easy way to eliminate the stretching is to simply resize the video. MeGUI suggests dimensions of 720x304, which very nearly matches the 2.35:1 aspect ratio of the movie. This works quite well, and I have no aspect ratio problems when I just resize the movie.

But I don't WANT to just resize the movie, because I want to keep as much picture detail as possible and going from 720x368 to 720x304 means discarding 64 rows of video.

So I select "clever anamorphic" mode with the "overcrop to mod16" option. To finish the script, I let MeGUI analyze the file and determine that it's progressive and does not need to be deinterlaced. My AVS script looks like this:
# Set DAR in encoder to 11887 : 5000. The following line is for automatic signalling
global MeGUI_darx = 11887
global MeGUI_dary = 5000

DGDecode_mpeg2source("H:\LEGALLYBLONDE\VIDEO_TS\VTS_09_1 - 0xE0 - Video - MPEG-2 - 720x480 (NTSC) - 16~9 - Letterboxed.d2v")
crop( 0, 54, 0, -58)
LanczosResize(720,368)
Undot()

OK, now is when I start to lose my mind. I notice that my DAR is being set to 11887:5000, which is pretty close to 2.35:1. This seems sensible enough to me -- I want to view the movie at the movie's actual aspect ratio. But in MeGUI's "preview AVS script" window, the video still looks stretched.

I go ahead and encode the video anyway (using the PD-PS3-Xbox360" profile), and end up with a .mp4 file. When I play that file in VLC, the video is still stretched. The aspect ratio has not changed visibly from the original MeGUI preview window.

VLC tells me that my new .mp4 file has 720x368 both for its "resolution" and its "display resolution". And when I take the .mp4 file and feed it to MediaInfo, it tells me that the "Display Aspect Ratio" is 1.957.

Why?

I mean, the AVS script explicitly set the DARX and DARY for a DAR of 2.35:1. But it looks like those values were not used for anything in the actual encoding process?

On a whim, I have tried manually editing the AVS script to use other values for DARX and DARY. I have used 16:9, 4:3, 1.77:1, and a few others. Regardless of which values I use, they have no effect whatsoever.

That is, when I encode the file I ALWAYS end up with a DAR that is derived strictly from the pixel dimensions (720/368=1.957), instead of from the DAR value specified in the AVS script.

Someone please help me understand what is going on here? Is this stuff actually broken, or am I doing something stupid?

If I can't get the anamorphic mode to work, another option might be to upscale the video to a resolution based on 1280x720 -- that way all 368 pixel rows would at least be used. But that seems like a dumb approach, honestly -- any opinions or better suggestions?

Please?!

Thanks in advance!

saint-francis
6th May 2008, 01:39
Well your problem is news to me. Clever anamorphic encoding works fine for me and always has. You might want to try uninstalling and reinstalling everything related to the process. As a last ditch effort you could simply not resize when encoding and when you mux give Yamb or mkvtoolnix the DAR you want. If you know that when you select CAE it doesn't do anything you could just use the dimensions it gives you when muxing.

Jom
6th May 2008, 02:02
Hi.

In your AVS script you have :
LanczosResize(720,368)

If you are only overcropping you shouldn't have a resize.
Maybe thats throwing it ?

In the avs preview, there's a tick box 'DAR' that will show the clip with the correct aspect ratio

In the megui log you should be able to see the x264 command used to encode, somewhere in there should be --sar 11887:5000
edit: maybe you don't see --sar in the encoding options

Is it present ?

psychohobbit
6th May 2008, 05:52
Hm, you're right -- the "LanczosResize(720,368)" shouldn't be in the AVS script. I think I had the Clever Anamorphic set to "resize to mod16" instead of "overcrop" when I did the cut 'n paste. When it is set to "overcrop", the script looks like this:
# Set DAR in encoder to 11887 : 5000. The following line is for automatic signalling
global MeGUI_darx = 11887
global MeGUI_dary = 5000
DGDecode_mpeg2source("H:\LEGALLYBLONDE\VIDEO_TS\VTS_09_1 - 0xE0 - Video - MPEG-2 - 720x480 (NTSC) - 16~9 - Letterboxed.d2v")
#deinterlace
crop( 0, 54, 0, -58)

#resize
#denoise

I just tried another decode using the above script (with the addition of a TRIM line to keep things small). Here are the x264 command lines for both passes:

Job commandline: "C:\Program Files\megui\tools\x264\x264.exe" --pass 1 --bitrate 1000 --stats "H:\LEGALLYBLONDE\VIDEO_TS\lb2.stats" --level 4.1 --bframes 3 --direct auto --subme 1 --partitions none --ipratio 1.1 --pbratio 1.1 --vbv-bufsize 9000 --vbv-maxrate 24000 --qcomp 0.5 --me dia --threads auto --thread-input --progress --no-psnr --no-ssim --output NUL "H:\LEGALLYBLONDE\VIDEO_TS\lb2.avs"

Job commandline: "C:\Program Files\megui\tools\x264\x264.exe" --pass 2 --bitrate 1000 --stats "H:\LEGALLYBLONDE\VIDEO_TS\lb2.stats" --level 4.1 --bframes 3 --weightb --direct auto --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --ipratio 1.1 --pbratio 1.1 --vbv-bufsize 9000 --vbv-maxrate 24000 --qcomp 0.5 --threads auto --thread-input --progress --no-psnr --no-ssim --output "H:\LEGALLYBLONDE\VIDEO_TS\lb2.mp4" "H:\LEGALLYBLONDE\VIDEO_TS\lb2.avs"

As you can see, there is no "--sar" option being passed to x264. Can you think of any reasons this would happen?

As for the "DAR" tick box you mention, well, I don't see it anywhere. In the AviSynth Script Creator, I select "Preview AVS Script" and the preview window appears. There are no tick boxes in that window anywhere, just buttons for "go back", "play/stop", "advance", "go to frame", and "original size".

So now I'm wondering if there's a new version of this software that I should be using? I just downloaded MeGUI and all its friends a few days ago, and everything looks to be updated to the latest versions. MeGUI itself is version 0.2.6.1046...

Any other ideas? In the meantime, I will try saint-francis' suggestion and reinstall everything related to MeGUI -- but it should be a pretty clean and self-contained installation, so I'm not hopeful this will change anything.

psychohobbit
6th May 2008, 07:06
Hm, saint-francis had it right after all.

I uninstalled MeGUI, AviSynth, ffdshow, and Haali Media splitter, and reinstalled AviSynth and MeGUI in that order, leaving the other two uninstalled.

Now Clever Anamorphic is working, x264 gets a --sar parameter, and MediaInfo reports that my 720x368 file has an aspect ratio of 2.35:1. Yay!

Thank you both for your help, I appreciate it!

Merovingian1
9th June 2009, 07:22
I have a movie that I would like to encode using the x264 codec via meGUI. The specs are listed bellow :

DVD9 (no BruRay or HD… for now:)
Format – MPEG Video Version 2
Standard – PAL
Display Aspect Ratio – 1.778 (16/9) / 2.35:1 (That’s what it says on the package but I think it’s 2.37:1)

Anyway, I find it a bit hard to get my head around resizing and the whole aspect ratio concept but most of all, I can’t understand the idea of “Clever Anamorphic Encoding”. Here is what I know (it is my first video encoding attempt so…).

This thing (Movie) is 720x576 after the anamorphic encoding it suffered, so I assume it actually has a 1024x576 resolution (or does it have bits for 720x576 and it’s only stretched to 1024x576 for correct viewing ? ). When I open the *.d2v file in AviSynth Script Creator, I get a preview of the stretched movie (720x576) which is correct. Next, I remove the black lines surrounding the actual frame (using the Crop arrows) and I am left with a stretched frame (no problems here).

What I think I should do is make adjustments to the resize (and some more cropping if needed) so that the horizontal / vertical resolution give me an aspect ratio of approximately 2.370 (I got 2.368 and Width x Height = 720x304 while the cropped frame is 720x432).

The problem with this approach is that I waste 128 pixels of vertical resolution (which means less precision in the encoded output) so that the aspect ratio would be correct (and it needs to be correct). I mean, this movie has a bitrate high enough to support 1024*576 pixels and in the end the *.mkv will have a smaller resolution. I want to preserve as much of the original quality as I can so…

I check the Clever Anamorphic Encoding with the overcrop mod16 option. It does not let me resize which is fair and it will write a ratio flag in the AviSynth script so that the player knows how to properly stretch it. This brings me to my question:

– Do I have to tweak the cropping settings to achieve an aspect ratio of approximately 2.370 ?
– If this works, the video will be reported as 720x432 in MediaInfo and stretched to 1024x432 when I play it back ?
– If the above work and I do the “Clever Anamorphic Encoding with overcrop mod16” is it worth it? I mean, does the DVD have enough bitrate for the 1024*576 resolution so that I am not wasting bits encoding at a high resolution (because what I think is that the DVD has bits for 720pixels horizontally and not for 1024, but I am not certain).

Thanx in advance.

Any feedback would be really appreciated

Betsy25
9th June 2009, 09:51
Not to really hijack this thread in any way, tell me if I do, but I wonder if there are any tools avaliable (thinking about MediaInfo, G-Spot, DGIndex, etc....) that DO actually correctly detect an anamorphic DVD.

AFAIK, there is no single tool able to detect this correctly.

SeeMoreDigital
9th June 2009, 18:34
Not to really hijack this thread in any way, tell me if I do, but I wonder if there are any tools avaliable (thinking about MediaInfo, G-Spot, DGIndex, etc....) that DO actually correctly detect an anamorphic DVD.

AFAIK, there is no single tool able to detect this correctly.With store bought DVD's, the correct aspect ratio signalling information is placed within the MPEG-2 stream.

Provided all the tools you mentioned look at the MPEG-2 stream (not the .IFO file), they'll all give you the correct information, ie: either 4:3 or 16:9.

Kurtnoise
10th June 2009, 09:07
Provided all the tools you mentioned look at the MPEG-2 stream (not the .IFO file), they'll all give you the correct information, ie: either 4:3 or 16:9.
this is stored also in the IFO...

SeeMoreDigital
10th June 2009, 09:13
this is stored also in the IFO...True... but the aspect ratio signalling information in the .IFO file is not always accurate :scared:

Merovingian1
10th June 2009, 10:58
SeeMoreDigital

I read your guides on PAL/NTSC and their differences.
I am still a bit confused though. In the scenario described in my previous post, if i encode the video using "Clever Anamorphic with overcropmod16", the final video will have the correct aspect ratio as signaled in the AviSynth Script. If i use MediaPlayer Classic, to play back a sample of the movie i encoded, it will default to a resolution of ~ 1024x432 (due to the 2.37 flag imposed by Clever Anamorphic which is correct). In MediaInfo it will be (720x432 2.37) because of the anamorphic encode i did. Should i do it this way though ?? I mean, if the DVD does not have the bits for 1024 and it has bits for only 720, what do you think i should do ?? Keep in mind i want to use the 432 of vertical resolution.

I already know how to resize and maintain the proper AR without using Clever Anamorphic, but if Clever Anamorphic gives better image presicion i would like to go this way.

Thanks in advance....

SeeMoreDigital
10th June 2009, 17:46
Ultimately it's up-to you what resolution you use to generate your encodes....

Some people prefer to generate cropped encodes with "non-square" pixel (ie: anamorphic) resolutions, such as: 720x432. Others prefer to generate cropped encodes with "square" pixel resolutions, such as: 1024x432.

When the video decoding chip-sets within hardware players were limited to support a maximum resolution of 720x576 (total 414,720) pixels, you had to generate anamorphic encodes if you wanted the image pixel area of your encode to match that of the source.

Today however, the video decoding chip-sets within hardware players are able to support a maximum resolution of 1920x1088 (total 2,088,960) pixels. So you're perfectly able to generate encodes at say, 1024x432 (total 442,368) pixels ;)

Merovingian1
10th June 2009, 18:20
Most helpfull.

I will go with the Anamorphic Overcrop then.
This way i'' preserve the initial resolution.

Thanx.