Log in

View Full Version : Anamorphic encode. Correct Aspect Ratio?


Backflip
16th June 2005, 18:11
Hi I encoded a small music video from the SAW (PAL) DVD using the File input option of AutoGK. I used the 1:1 - Original option to get a anamorphically encoded file. My file (VOB) is 4:3. After that I use MMG to create a MKV file.

Now, the question is - how do I know what vertical resolution number to give it so the display is the correct AR? There's no information about the music video's AR on the casing etc of the original DVD.

This is my log:

[6/14/2005 11:44:35 AM] AutoGK 2.08b
[6/14/2005 11:44:35 AM] OS: WinXP (5.1.2600).2
[6/14/2005 11:44:35 AM] Job started.
[6/14/2005 11:44:35 AM] Input file: VTS_06_1.VOB
[6/14/2005 11:44:35 AM] Output file: C:\New Folder (3)\1.avi
[6/14/2005 11:44:35 AM] Output codec: XviD
[6/14/2005 11:44:35 AM] Audio1: Audio Stream 0 AC3
[6/14/2005 11:44:35 AM] Subtitles: none
[6/14/2005 11:44:35 AM] Format: .AVI
[6/14/2005 11:44:35 AM] Target size: 70Mb
[6/14/2005 11:44:35 AM] Custom audio settings: AC3
[6/14/2005 11:44:35 AM] Started encoding.
[6/14/2005 11:44:35 AM] Demuxing and indexing.
[6/14/2005 11:44:38 AM] Processing file: C:\New Folder (3)\VTS_06_1.VOB
[6/14/2005 11:44:38 AM] Source aspect ratio: 4:3
[6/14/2005 11:44:38 AM] Manual aspect ratio: Original
[6/14/2005 11:44:38 AM] Source resolution: 720x576
[6/14/2005 11:44:38 AM] Found PAL source.
[6/14/2005 11:44:38 AM] Analyzing source.
[6/14/2005 11:45:10 AM] Source has percentage of interlacing in motion areas: 58.05
[6/14/2005 11:45:10 AM] Source is considered to be interlaced.
[6/14/2005 11:45:10 AM] Output will contain 6139 frames
[6/14/2005 11:45:10 AM] Audio1 size: 6,875,008 bytes (6.56 Mb)
[6/14/2005 11:45:10 AM] Overhead: 40,960 bytes (0.04 Mb)
[6/14/2005 11:45:10 AM] Video size: 66,484,352 bytes (63.40 Mb)
[6/14/2005 11:45:10 AM] Running compressibility test.
[6/14/2005 11:45:10 AM] Writing the following script to C:\New Folder (3)\agk_tmp\1_comptest.avs
===========================================================
LoadPlugin("C:\PROGRA~1\AutoGK\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\autocrop.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\RemoveGrainSSE2.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\kerneldeint.dll")

movie = mpeg2source("C:\New Folder (3)\agk_tmp\1.d2v")
cropclip = autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=10,aspect=0,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
fixed_aspect = 1
c_width = width(cropclip)
c_height = round(height(cropclip) / fixed_aspect)
input_par = float(c_width)/float(c_height)
out_width = 640
out_height = round(float(out_width) / input_par)
hmod = out_height - (floor(out_height / 16 ) * 16)
out_height = (hmod > 4) ? (out_height + (16 - hmod)) : (out_height - hmod)
new_aspect = (float(out_width) / float(out_height)) / fixed_aspect
KernelDeInt(movie,order=1,sharp=true)
autocrop(mode=0,wmultof=4,hmultof=4,samples=10,aspect=new_aspect,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
LanczosResize(out_width,out_height)
RemoveGrain(mode=2)
SelectRangeEvery(45,15)
===========================================================
[6/14/2005 11:47:18 AM] Duration was: 2 minutes 7 seconds
[6/14/2005 11:47:18 AM] Speed was: 15.83 fps.
[6/14/2005 11:47:18 AM] Compressibility percentage is: 87.79
[6/14/2005 11:47:18 AM] Chosen resolution is: 704x432 ( AR: 1.63 )
[6/14/2005 11:47:18 AM] Predicted comptest value is: 70.94
[6/14/2005 11:47:18 AM] Running first pass.
[6/14/2005 11:47:18 AM] Writing the following script to C:\New Folder (3)\agk_tmp\1_movie.avs
===========================================================
LoadPlugin("C:\PROGRA~1\AutoGK\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\autocrop.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\RemoveGrainSSE2.dll")
LoadPlugin("C:\PROGRA~1\AutoGK\filters\kerneldeint.dll")

movie = mpeg2source("C:\New Folder (3)\agk_tmp\1.d2v")
cropclip = autocrop(movie,mode=0,wmultof=4,hmultof=4,samples=10,aspect=0,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
fixed_aspect = 1
c_width = width(cropclip)
c_height = round(height(cropclip) / fixed_aspect)
input_par = float(c_width)/float(c_height)
out_width = 704
out_height = round(float(out_width) / input_par)
hmod = out_height - (floor(out_height / 16 ) * 16)
out_height = (hmod > 4) ? (out_height + (16 - hmod)) : (out_height - hmod)
new_aspect = (float(out_width) / float(out_height)) / fixed_aspect
KernelDeInt(movie,order=1,sharp=true)
autocrop(mode=0,wmultof=4,hmultof=4,samples=10,aspect=new_aspect,threshold=34,samplestartframe=0,leftadd=0,rightadd=0,topadd=0,bottomadd=0)
LanczosResize(out_width,out_height)
RemoveGrain(mode=2)
===========================================================
[6/14/2005 11:50:41 AM] Duration was: 3 minutes 23 seconds
[6/14/2005 11:50:41 AM] Speed was: 30.18 fps.
[6/14/2005 11:50:41 AM] Expected quality of first pass size: 74.09
[6/14/2005 11:50:41 AM] Running second pass.
[6/14/2005 11:56:45 AM] Duration was: 6 minutes 4 seconds
[6/14/2005 11:56:45 AM] Speed was: 16.86 fps.
[6/14/2005 11:56:45 AM] Job finished. Total time: 12 minutes 9 seconds


Do you simply take the vertical resolution number and multiple it by 1.33 (i.e. - 416 x 1.33) to get 554, so the final resolution would be 554 x 416? It seems wrong though? What is the correct way?

Thanks in advance to anyone that can help :)

Backflip
18th June 2005, 02:08
Ok, I think for a start my 416 x 1.33 is wrong, it should be 416 x 1.3333 (is this correct?), so resolution of the final video should be 555 x 416. Is this correct, yes/no?

Thanks for any help on this :)

manono
18th June 2005, 02:37
No.

Your resolution numbers should always be divisible by 16 (Mod16). Many recommend that the Horizontal res numbers be divisible by 32. So the Horizontal resolution should be 544, 560, or 576. I don't understand the rest of what you're trying to do, so I can't help with that. It all sounds pretty screwy to me, but like I said, I don't understand.

This next part may be wrong. However, the DVD is 720x480 (1.5:1) encoded with a DAR of 4:3. If you're going to reduce the resolution and still maintain 1:1, then you want to keep it at 1.5:1. So, 416 x 1.5 = 624. Based on my limited understanding of what you're doing, you want a 624x416 result, with a DAR of 4:3, which will then be read by MKV and resized properly. Just a guess, though. Try out a few solutions. It seems that it only takes 15 minutes or so to get results.

Backflip
18th June 2005, 06:22
Source resolution is 720x576. It's PAL version of Saw DVD. The main movie is 1.85:1, this is what it says on the box. However I don't know the AR of the music video extra which I'm trying to encode, because it doesn't mention its AR on the DVD box, but because it's fullscreen (plays in fullscreen when played on the DVD player) and AutoGK says it's 4:3, it must be 1.3333.

What I would like to do is encode to XviD video in an anamorphic manner, keeping as much horizontal width as possible with less regard to vertical height, because this provides better quality. I use AutoGK and the 1:1 - Original option to encode anamorphically.

First I ripped only the music video VOB file to hard disk, then input that file into AutoGK, then check the extra option (CTRL-F9 - Original).

Once that is all done, and I've got my XviD-video (704x416), I then load that into MKVMerge GUI and fill in the boxes next to Display width/height, which are 555 x 416

I'm following this guide:
http://www.therealbmd.com/guides/cronus/

============================================================

I've also encoded a movie which is 2.35:1 (says this on the box). It originally came out as - 608x368. I multiplied 368 by 2.35 and that comes to 864.8, so I round up to 865, with my final resolution being 865x368. In MKVMerge GUI these numbers - 865 x 368 is what I put in the Display width/height boxes. Is this completely wrong?

When I play this file in MPlayer it goes from 865x368 => 866x368. MPlayer is saying that the ratio is 2.35:1.

Hhmm, I think I follow now, I didn't know that the chosen horizontal number had to be divisible by 16, I just use the closest number to the sum of 368x 2.35 which is 864.8, so 365. Which number should I use for 16 divisibility in this case^, should it be 864 or 880?

Thanks for the tips :)

ps - I still don't quite know what to do about the music video resolution as there is no indication of its AR on the Saw DVD box, the only thing I can go on is AutoGK saying it's actually 4:3, so it must be 1.3333?

manono
18th June 2005, 06:57
I was careless, and didn't note that you were PAL. 720x576=1.25:1. So, if you're going to maintain the same ratio for the XviD as for the DVD for resizing by the player, then 416 x 1.25 = 520. 520 is only Mod8, so I guess it'll have to be either 512 or 528, with AutoGK taking care of the cropping to maintain the ratio. I have no idea how you got 704x416 unless this a widescreen 4:3 music video.

Sorry But I don't know anything about MKV. Maybe someone else will come along to help with that.

Backflip
24th June 2005, 08:01
Is 704x416 incorrect for 4:3 or 16:9? It's what AutoGK gave me, but it was encoded anamorphically.

What's a widescreen 4:3 music video?

Thanks for your help :)

manono
24th June 2005, 10:50
Hi-

Is 704x416 incorrect for 4:3 or 16:9?

It's certainly not 16:9. It's closer to being 4:3, if you've kept the original DAR, and are planning on having the player resize it.

What's a widescreen 4:3 music video?

16:9 and 4:3 are DARs. Open the vob in DGIndex, run the Preview, and see which you have. You said in the first post, and the log confirms, that it's 4:3.

Thanks for your help

I think I've probably confused the issue more than I've helped, as to this day I still haven't the foggiest notion what you're doing.

stephanV
24th June 2005, 12:09
Personally I believe there is little value in using anamorphic encodes if you are going to resize the video. Your statement that it is more important to keep horizontal resolution is a bit questionable. (The guide you follow even contradicts it ;) ). Also note how the guide uses GK and not AutoGK.

It appears to me that your video has black bars that are cropped out of it, or AutoGK is completely screwing up its resizing (or maybe you are doing that manually). If it is full screen 720x576 4:3 then a 1:1 resize should also result in 5:4 ratio after width and height are resized.

In any case, encoding a 704x416 movie as anamorphic and then setting the DAR to 555x416 (you dont really have to follow the mod16 rule here, maybe mod2 is in place) is a waste of bandwidth.

Backflip
25th June 2005, 07:36
I decided to encode using standard settings. I input only:
File Size = 70MB
Audio track(s) = AC3
Output resolution = Auto width

Pretty much AutoGK does everything else.

Resulting file is 700x400. When played in MPlayer it prescales to 1.80:1. It does have borders.

That seem right? Or is there bad cropping or something like that going on?

ps - hhm, I thought anamorphically encoding resulted in better quality, that's why DVD's use it these days.

stephanV
25th June 2005, 16:09
maybe you could post a (full-)screen shot of a source (not encoded) frame?

Anamorphic has in principle nothing to do with quality, its just that the SARs (sample aspect ratio) for TVs and PCs are different.

Backflip
27th June 2005, 10:06
So what karl_lillevold (http://forum.doom9.org/showthread.php?t=40572&highlight=anamorphic) says is incorrect?

And the gain you see in bits/pixel in the statistics if you're using AutoRV10 and the anamorphic encoding especially is false?

Hhm, I was thinking of posting a screenshot, but free reliable long-retention picture hosting is difficult to come by :/ Anyone know of one?

stephanV
27th June 2005, 12:06
No, you are not reading what Karl Lillevold is saying.

Here is an example: After cropping, the video size could be 712x368. The correct aspect ratio after resizing should be 2.35:1. Normally you would resize to 640x272 and encode at this resolution. If you have more than enough bits, but not a lot more than you need, you will get some improvement by resizing to 720x304 instead, but that's only half way there. For true anamorphic encoding at the native resolution, do not resize in AVISynth, but resize in producer to 856x364 (364 * 2.35 = 856). Producer will then encode at 712x368, and RealOne will stretch this to 856x364 on playback. This resolution looks just awesome, and much better than 640x272!

Yes of course, if you have enough bits encoding at 712x368 will be better than 640x272. This has nothing to do with the video being anamorphic or not, this is because 712x368 contains 50% more info than 640x272. IMO if you encode anamorphic you should retain the original resolution (ignoring cropping, since that doesnt change SAR). What you are doing is AND resizing AND using anamorphic. So using the original example, instead of resizing to 640x272 you could also resize to 572x304 and use anamorpic signalling for that, but the amount of info you have retained then is more or less the same. Anamorphic encodes are mainly useful if you keep full resolution, which you don't. Or even better said, anamorphic encodes are a way to keep full resolution without having to worry about AR settings in your player.

I believe there is a sticky topic about imgae hosting in this forum. ---> www.imageshack.us

Backflip
3rd July 2005, 12:13
Thanks, I get what you're saying :)

BTW - AutoRV10 has anamorphic encoding at non-full resolutions also where it goes from where the video is encoded at a lower ratio resolution, but has anamorphic signalling for 640x272 for example. This significantly improves the bits/pixel ratio, so I just assumed it's better. Looking back at it now, maybe it's better to encode normally IF your bits/pixel ratio is close enough to 0.225 rather than go from a lower resolution with anamorphic signal for 640x272 for example.

Also, I've found that the video is certainly 4:3, it just seemed weird to me that it had borders :P

SeeMoreDigital
3rd July 2005, 12:48
At the end of the day you have to decide what type of encode you want...

Do you want to generate an encode with "square pixels". Where-by the encodes pixel ratio matches (or closely matches) the source movies aspect ratio - ie: 720x384 = 1.85:1 approx.

Or do you want to generate an encode with "anamorphic signalling". Where-by the encodes pixel ratio does not mathematically match the source movies aspect ratio, but is given "anamorphic signalling" to do so.

In effect, anamorphic signalling is used to distort an square shaped pixel to a rectangular shaped pixel.


Cheers

Backflip
15th July 2005, 16:25
Sorry about this thread, almost all of it is wrong with respect to what I was trying to achieve.

Firstly, what got me confused about the music video I was attempting to encode was the borders, I assumed that video of a 4:3 nature needed to have no or very little borders. I've since read that it's common to have videos like this where it's 4:3 even thought there are quite big borders.

Now just to go back to anamorphic encoding, my objective is to properly calculate how my video should be stretched so it is displayed properly. I want to encode at a low resolution (but not too low) like 5 or 4**x***, then have that video displayed at a different resolution on playback. My problem is I don't know how to calculate the correct display resolution :/ As an anamorphic encoding related example, take AutoRV10. There is builtin support for anamorphic specificating. I'm not so much into using the full DVD resolution option, but I use the option where you encode at a low resolution, say 5 or 4**x***, but stretch that to your intended resolution of 6 or 7**x***.

Example, I encoded Sideways DVD. Log:

Crop Movie:
Top - 12
Left -
Right -
Bottom - 12
Width x Height = 720,552

Ratio Value:
Crop Ratio % - 1.86
Resize Ratio % - 1.875
Aspect Error % - -0.8

Resize Movie:
Video Format - PAL
Aspect Ratio - 16:9
Filter Quality - Bicubic Precision
Resize To - 720, 384
Use Anamorphic Resize
External Resize - 500, 384

How do I calculate the display resolution if say I'm trying to do this sort of thing using GordianKnot + MKVMerge? 384 x 1.85? Also, I tried putting 500 x 384 into GordianKnot, but with the recomended MOD-16 it's not possible. Why does AutoRV10 have an external resize of 500 x 384? Is there a program that can automatically calculate the resize values, especially for XviD and GK?

Main reason I like the anamorphic option is because to my eyes the quality looks better, also apparent when you compare bits/pixel ratio.


(On a sidenote - I like RealVideo10 very much, but it appears my primary media player (Xbox with Xbox Media Center installed) somewhat hiccups when viewing RV10 + AC3 *MKV* files, it plays XviD + AC3 *MKV* fine.

Also, on a question related to RV10, I do very much like the format, but I've noticed that in parts it can get quite large blocks. Maybe this is something to do with the way I encode the file? I've found that in flat planes (such as a blue sky) or dimly lit room with a wall large blocks can appear, on the wall itself. XviD exhibits far less noticeable blockiness (almost no blockiness).)

Thanks :)

(edit - oh, I think I've got it now, although GK gives me different ideal figures - i.e. - 480 x 368, which best should be 688 x 368 displayed res values, I think?)

Backflip
18th July 2005, 04:41
Hhmm, been checking out things and thought may as well try x264 with defaults used (CABAC included -- no fast first pass, using Lanczos). Same cropping as above, encoded at 480 x 368 to AVI (kept 6CH AC3) -- 1404MB target size. Came out at pretty much that size. Then I used MKVMerge for splitting, giving the display resolution as 688 x 368 (688 -- nearest 16). No idea how to calculate the AR error, but 680.8 is the closest to 1:85(5), so maybe I should just use 681, just for the sake of better AR (well closer to 1:85), but then again haven't taken into account other factors (whatever those factors might be?). I guess there'll be some loss in quality? Apart from watching to judge the loss.

Sadly, Xbox Media Center stops in the opening frames when I try to play the x264 encoded files (even though it's encoded at a low 480 x 368). I was just hoping it would play. MPlayer for windows plays the files well (on a AMD Athlon 3000+ though).

Just taking a glancing view I like x264's quality/detail retention. It's somewhat similar to RV10 EHQ100, although I've found that RV10 is very blocky (excessively) in certain scene areas (like all the blocks collect in one area) while x264 has more distributed blocks, if any, giving a better appearance.

I also tried encoding Sideways DVD using XviD with GMC/QPel/B-VOP (2)/MPEG/IPB (2)/VHQ 4 (b-frames too)/MSP 6/Chroma Motion. Everything else at default. Apart from the undersizing, quality was quite impressive, although credits were not so good quality (maybe should just leave them instead of lower quality).

Could anyone suggest me a good 1000-1400 CQM (close to 1000 than 1400 mostly)? Also, if I were to use a CQM would I get a more exact output file size even with IPB capped at 2 while using most of the other options minus QPel, maybe.

Backflip
20th July 2005, 09:25
Also, thanks manono. What you were saying is exactly what I wanted to do. I was mistakenly thinking AutoGK calculated the AR etc all automatically.

Also, I found the problem with undersizing I was getting. The IPB capping at 2, lol. I never did do an encode with IPB's at 1.

Anyways I think I've got everything down except maybe a couple of things. This is more of a question for AutoRV10 users, possibly. Now I've noticed that if I anamorphically encode I get figures of say -- 624 x 336, but then I look at the second lot of figures (External Resize) and it's 380 x 336. 380 isn't divisible by 8 (AutoRV10 works in mod 8).

How do you come to this figure -- 380 x 336? I tried setting GordianKnot at mod 8 and 1:1, but it only comes out at 440 x 336. I'm kind of confused about it.

I think I'll go back to normal encoding for the time being. And use AutoRV10 whenever I feel like properly encoding anamorphically (when source is pretty compressible).