Log in

View Full Version : Can't find what was leading to "Evaluate: Unrecognized exception"


Razorblade2000
30th August 2004, 20:07
I try to create a script that is able to resize every input to a resolution of 480*X while keeping the original aspect ratio :D
My problem: Some files give me a "Evaluate: Unrecognized exception" error in lines 19 and line 13 :(
I don't really know what might be the cause :(
Using the RC3 of avisynt 2.5.5
(maybe my lame comments will help you :D)
hope it's not still this: http://forum.doom9.org/showthread.php?s=&threadid=80737



##Select your source
directshowsource("D:\some.avi")

##This it the dll you need: http://www.videofringe.com/autocrop/
## this plugin should crop black borders so d2v input can also be resized correctly
Autocrop(0)
## replace the 0 by a 1 and you'll have the cropping values displayed via overlay

#The Maintainaspect stuff was done by CropsyX (doom 9 forum)... thx :D
#I think lanczos is the best method for rmvb... we can need any detail we get, don't we? :D
ResizeMaintainAspectWidth(480,"Lanczosresize")


##This is the nifty function which will detext and keep aspect ratio
function ResizeMaintainAspectWidth(clip c,int newwidth,string resizefn) {
nh=floor(eval(string(c.height)+". * "+string(newwidth)+". / "+string(c.width)+"."))
return eval(resizefn+"(c,"+string(newwidth)+","+string(nh)+")")
}


### the function works like this:
### the first line of the function gets your input (the new heigth):
# function ResizeMaintainAspectWidth(clip c,int newwidth,string resizefn) {

# "int newwidth"
### the width you want the video to have

# nh=floor(eval(string(c.height)+". * "+string(newwidth)+". / "+string(c.width)+"."))
### here comes the new variable nh (new heigth) -> heigth * (new width / old width)
### (new width / old width) is the factor the video will be shrunk, both horizontally and vertically
### --> the "heigth * (new width / old width)" will multiply the current heigth by this factor and therefore give you the new heigth

Manao
30th August 2004, 21:22
There's a lot of things that can go wrong : the ResizeMaintainAspectWidth doesn't even check whether it's resizing to even dimensions ( necessary if you're YUY2 or YV12 ). Since the resize filter is used through 'Eval', I don't know if you can catch the right error message.

So don't used that function, especially if it's only to avoid you a multiplication / division by hand...

Razorblade2000
30th August 2004, 21:36
Is there any other function similar to this?
I need an avisynth script as I plan to implement it into a batch encoding app :(

hmmm... I like the script as it's quite easy and seems to work...
couldn't I just check if round(nh/2) = nh(2) and else add 1 to nh?

Manao
30th August 2004, 21:46
Yes you could. But if it's YV12, it must be mod4.

I'd also avoid the use of "eval", which is necessary only to make possible the choice of the resizer, which you won't need with your batch encode.

I's use the following function : function LanczosResizeMaintainingRatio(clip c, int nw)
{
ow = Width(c)
oh = Height(c)
nh = nw * oh / ow
nh = (nh / 4) * 4
return c.LanczosResize(nw, nh)
}

Razorblade2000
30th August 2004, 21:51
ahhhh, cool :D
thanks