Log in

View Full Version : Problem with my script resizing an avi to encode it for DVD


dominik
12th May 2003, 16:34
What is wrong with this script??

avisource("d:\stuff\file.avi")
sizey = (framerate==25) ? 576 : 480
faktorxy = (framerate==25) ? 1.422222 : 1.185185
faktorx = 720/width
newheight = round(height*faktorx*faktorxy)
bicubicresize(720,newheight)
halftooless = (sizey-newheight)/2
top = floor(halftooless)
bottom = ceil(halftooless)
addborders(0,top,0,bottom)

The problem is that the variable "faktorx" gets ignored. Doesn't matter if i set it to 720/width, 1000/width,... always it bahaves at "newheight=..." like it would be "faktorx = 1". But if I set for example "faktorx = 1.3" it does behave like you would expect it. Please Please help me!

Wilbert
12th May 2003, 17:03
faktorx = 720/width
Maybe this helps: faktorx = 720./width ?
Otherwise:

clip = avisource(...)
.. = ..
factorx = 720./clip.width

dominik
12th May 2003, 17:42
"faktorx = 720./width" works! The point solved my problem!

Thankx a lot!:)

But could you tell me more about that point before the slash? What does it do? There's nothing in the documentation about that.

sh0dan
12th May 2003, 20:58
It makes avisynth do the calculation in float point - otherwise it is processed as an integer, and rounding off the numbers below the integer part.

dominik
12th May 2003, 21:28
So I should write "halftooless = (sizey-newheight)./2" instead of "halftooless = (sizey-newheight)/2". Right? I'm too lazy to check it out right now, if sometimes you'll get 481 as result without ".".

sh0dan
12th May 2003, 21:39
No - use:

halftooless = float(sizey-newheight)/2.0

dominik
12th May 2003, 21:58
I think I understand right now "720." means "720.0" and it tells to be float? If I understand you "720./width" is wrong, but "720./float(width)" is right ?!

dominik
14th May 2003, 17:22
I mean, that if it is not necessery to use "720.0/float(width)", but it's enough to use "720.0/width", it should be enough to use "(sizey-newheight)/2.0" instead of "float(sizey-newheight)/2.0"? Right or wrong?

sh0dan
14th May 2003, 17:33
I think the first values decides if the expression should be treated as integer or float, IIRC.

Wilbert
14th May 2003, 17:33
Right.

dominik
14th May 2003, 18:35
So "float(sizey-newheight)/2" should give a float result.

Wilbert
15th May 2003, 09:18
There are internal filters called IsFloat and IsInt. Together with the subtitle filter you can check your questions ...