Log in

View Full Version : could anyone help me on this script?


terrense
18th April 2006, 17:58
here's my script.

the size of the clip i generate is 608x336, so the aspect is about 1.8

then i use a variable "r" to store the aspect of the clip and call a condition script.

now the problem is: the conditoin is TRUE, but avisynth does not recognize it as i expected.

what's the problem of my script? does avisynth take "r" as string? how do i convert it to number?

c = BlankClip(color=$009900, pixel_type="yuy2", length=300, fps=29.97).LanczosResize(608,336)

r = c.Width()/c.Height()

function resize480(theclip)
{
v = theclip.LanczosResize(480,272)
v = v.AddBorders(100,0,100,0)
return v
}

myVal = r>1 && r<1.83 ?
\ "resize480(c)" :
\ "v = c.LanczosResize(720,440)
v = v.AddBorders(0,50,0,50)
return v"

eval(myVal)

foxyshadis
18th April 2006, 18:22
You could do it more simply by using:

r>1 && r<1.83 ? c.resize480() : c.LanczosResize(720,440).AddBorders(0,50,0,50)

To directly troubleshoot your problem, I'd suggest you use subtitle(myval) or subtitle(string(r)).

terrense
18th April 2006, 18:33
thx buddy.

i tried subtitle(string(r)) and subtitle(string(c.Width()/c.Height())), it displays a number "1" on the screen.

that's not right because c.Width()/c.Height() ~= 1.8

why is that?

terrense
18th April 2006, 18:55
c = BlankClip(color=$009900, pixel_type="yuy2", length=300, fps=29.97).LanczosResize(608,336)
subtitle(c,string(c.Width/c.Height))

the subtitle is "1"..... what's wrong with avisynth?

foxyshadis
18th April 2006, 19:42
oh right, c.width and c.height are both integers, so the end result of the division is an integer (like certain other languages). Use:

c.width*1.0/c.height

terrense
18th April 2006, 19:48
a million thanks~~~~~~~~!!!!!!!!!!!!!!