Log in

View Full Version : avisynth resize..


etain
8th April 2006, 22:14
hello.

i need help here...i tryed to read a guide but i found it difficelt to understand..(trough the guide)

lets say that i have a movie with a resolution:

640*272

if i want to resize it to 720*480 ntsc...

how do i calculate the resize...the stages and all....
how do i get from 640*272 to 720*480?

dont just give me the answer..explain to me how you got there.
if its not to hard to do...
tnxx
etain

foxyshadis
8th April 2006, 22:30
This should explain the algebra:

fwidth=720
fheight=480
lanczosresize(fwidth,m(4,fwidth*1./width*height)) # m4 just ensures a mod4 result, 1. is required to convert to float
borders=fheight-height # height is now the resized height
addborders(0,borders/2,0,(borders+1)/2) # +1 ensures you get an even result

# helper function
function m(int r, float x) {return(x<16?16:int(round(x/float(r))*r))}

There are other considerations, like, it won't work for 4/3 (you're messing with width instead of height), and you should align borders to mod-16 boundaries if possible, but that would obscure the basic logic. You can just tweak the formulae for mod-16, like this:

lanczosresize(fwidth,m(16,fwidth*1./width*height)) # m16 just ensures a mod16 result
borders=fheight-height
addborders(0,borders/32*16,0,((borders+1)/2+15)/16*16)

But that might incur an aspect ratio problem, which means fiddling with the width if the error is more than so much... etc.

This is typed freehand, so I might've made an error, sorry. [Tested now, I did make a few errors, fixed now.]

Note that you can always just skip all this and use lanczosresize(720,480) and set your aspect ratio in the the container. That's how anamorphic dvds work, and it depends on how much bitrate you have to spend whether that's good or not.