3

How can i resize a video to 480 pixels high in AviSynth, while maintaining aspect ratio? Assume, for simplicity sake, the Bilinear resize.

i've tried:

source = DirectShowSource("TheClip.avi")
resized = BilinearResize(source, target_height=480)
return resized

But that gives the error

Script error: Invalid arguments to function "BilinearResize"


Note: The reason i don't supply a width is that i don't know a width. The script is being used by a media server, that now forces the use of AviSynth in order to perform resizing. i don't know the size of any video that anyone might choose to play - but i do know i need it resized to x480.

i presume AviSynth can do something like:

resized=BilinearResize(source, source.width*480/source.height, 480)

but that also fails:

Resize: YUY2 destination width must be even

i could keep going, trying to find a way to AddBorders or Crop, to make the width mod4, mod8, or mod16. Or i could ask here and maybe there already is a way to perform aspect-preserving scaling.

Journeyman Geek
  • 133,878
Ian Boyd
  • 23,066

1 Answers1

4

I'm a bit rusty with avisynth scripting, but I think this should work to get the width, based in a target height of 480, and a given modulo value... I couldn't test it as I don't have avisynth installed ...

 srceH = source.height
 srceW = source.width
    AR = (float(srceW) / float(srceH))
 targH = 480
 targW = int(float(targH) * AR)
 coMod = 4   # The codec modulo requirement 
 targW = ((targW / coMod) * coMod)
Peter.O
  • 3,093