Log in

View Full Version : Resizing avi


qwer
12th August 2006, 03:12
Hello there,

I was attempting to convert an avi to an ifo (something I've accomplished before), but this time I've been encountering problems when trying to resize. The resolution of the avi is 352 x 288 and I'm trying to get it to fit 640x480. So I divided 640/352=1.8181. then multiplied to get 1.8181x288=524. So I used the avisynth script:
BicubicResize(720,524,0,0.5)
AddBorders(0, 0, 0, 0)

And when I run HC, I get an error saying that the resolution height is not a multiple of 16. I'm not quite sure how the resizing works, but I've been trying to follow the directions in the guide.

Thanks a bunch

Skelsgard
12th August 2006, 10:59
The resolution of the avi is 352 x 288 and I'm trying to get it to fit 640x480...


Whatīs its DAR? Is it 4:3 or actually 11:9?
From looking at the BicubicResize values it seems uīre trying to achieve a DVD compliant MPEG-2 (NTSC or PAL).
If your aviīs DAR is 4:3, then just use:
for NTSC --> BicubicResize(720,480,0,0.5)
for PAL --> BicubicResize(720,576,0,0.5)
No need to add borders.

If your Aviīs DAR is 11:9 (as in the movie played at its original size has the correct aspect ratio), then u need to set letterboxing to get it to display properly in a 4:3 display (wich I assume u do from this :"I'm trying to get it to fit 640x480").
Then, for NTSC --> BicubicResize(660,480,0,0.5)
AddBorders(0, 30, 0, 30)
For PAL --> BicubicResize(660,576,0,0.5)
AddBorders(0, 30, 0, 30)

qwer
12th August 2006, 16:48
Sorry for not mentioning it before, but the avi's DAR is 11:9.

I've been trying to follow the guide at: http://www.doom9.org/index.html?/mpg/avi2dvdr.htm, but I am a little confused.

So let me see if I have this straight. If I want to make it NTSC, and the DAR is 11:9, then I always use the line:
BicubicResize(660,480,0,0.5)
But, if the DAR is something else, then I have to change the height and overstretch it?

thanks again for your help

qwer
12th August 2006, 16:59
I just tried the script you gave me: BicubicResize(660,480,0,0.5), but I still get the error message that the height is not a multiple of 16...I don't understand at all

Skelsgard
12th August 2006, 22:56
I just tried the script you gave me: BicubicResize(660,480,0,0.5), but I still get the error message that the height is not a multiple of 16...I don't understand at all

Sorry, my bad about the resize value.
Set resize to BicubicResize(656,480,0,0.5) and AddBorders(0, 32, 0, 32) . --> I forgot HC asks for mod16 resizes :o (656 is mod16 --> 41 x 16 = 656).
Still, it looks "kinda" like a minor "bug" the fact that it recognizes the HEIGHT as being non-mod16 when itīs actually the width that is not (and only at some point cause at the end of the script the Addborders should take care of the mod16 compliancy as it feeds a 720px video to HC). (hank315: donīt byte my head off, I said "kinda" like a bug, not trying to FUD your excellent encoder).

If I want to make it NTSC, and the DAR is 11:9, then I always use the line:
BicubicResize(660,480,0,0.5)

Yes, but 656 instead of 660.

But, if the DAR is something else, then I have to change the height and overstretch it?

Not necessarily. Follow me thru the math and uīll understand how easy it actually is:

DVDīs MPEG-2 uses either 720 x 480 (NTSC) or 720 x 576 (PAL).
When u have a 16:9 video to create a "16:9 DAR" MPEG-2, it means that the totality of the frame will be used. Same when u have a 4:3 video to create a "4:3 DAR" MPEG-2. This is because no matter what size the output has (720 x 480 or 576), the DAR is gonna display it as intended (i.e. in 16:9 DAR, 720 x 480 will be viewed as if it were 854 x 480, wich is 16:9. And 720 x 576 will be displayed as 1024 x 576, also 16:9).
This situation only happens when, as I stated before, the video source has the same DAR than the output.
But when u have a different DAR in the source than the output (i.e. your case, a 11:9 DAR source to be put in a 4:3 DAR output) is when u need to letterbox.
So u do the maths (with your case, a 4:3 DAR output):
a 11:9 DAR compared to a 4:3 DAR means that, if I set an equal value for the height of both DARs, the value of the width of the 11:9 is gonna be smaller than the one of the 4:3.
As such:

http://img47.imageshack.us/img47/7349/darpf2.jpg

When adding a 16:9 DAR, this one is wider than both 4:3 and 11:9.
Then, if I want to put a 11:9 source in a 4:3 output, I need to fill the pixels on each side to achieve the proper width for the given height. I.e. in your case, the file would be 586 x 480 in a 640 x 480 container. The height is the same, so the width must be rectified. (640 - 480) / 2 = 27 px on each side to reach a 4:3 picture.
But DAR refers to the size it will be displayed at, not the actual size of the picture.
And, when creating DVD MPEG-2, the sizes are fixed, i.e. NTSC at 720 x 480, wich is neither 16:9 nor 4:3 picture.
Therefore u need to calculate what size (width or height) must the source video have when "framed" into a X:X output so when the DAR is applied, the result will give u a display with the pictureīs proper aspect ratio.

The math:
If my source is 11:9 to be put in a 720 x 480 "4:3 DAR" output, then:
11 ------ 9
X ------ 480

480 x 11 /9 = 586 ---> but only if my output were 640 x 480.
As my output is 720 instead of 640, then:
640 ------ 586
720 ------ X

X = 720 x 586 / 640 = 660 (rounded).
But 660 is not mod16, so HC will tell on it. So I go to the nearest mod16 value: 656, since its closer than 672, giving me a better AR.

Then, for a 656 px width I need --> [720 - 656] / 2 = 32 px, on each side to reach the 720 px width of DVD MPEG-2.
Itīs true that one can just resize to 586px, then fill sides with 27px to reach 640px and then resize to 720px, but the less resizing processes, the better.

Now, an example with "2.35:1 DAR" source in "16:9 DAR" output in NTSC.
In this case, since is the 2.35:1 source the one that itīs gonna be fitted into the 16:9 output, the 16:9 represents the maximum values for width and height. So, as the 2.35:1 source can not be higher or wider than the 16:9-output values and being the WIDTH the only parameter that the 2.35:1 source can use at its maximum value without trespassing the 16:9 frame size, is the width the one that is gonna be taken as equal for both.
So in a 16:9 DAR, u have a 854 x 480 px frame size. That means that the 2.35:1 DAR has a height of --> 854 x 1 / 2.35 = 364 (rounded).

http://img158.imageshack.us/img158/4186/dar2od9.jpg

So when fitting 2.35:1 DAR in 16:9 output, u can use a 720 x 364 px, then letterbox the top and botton with AddBorders (0, 58, 0, 58) to reach 480. <--- [480 - 364] / 2 = 58px

Cheers.

Edit:wording