Log in

View Full Version : Animate() and script functions?


Xesdeeni
20th November 2002, 16:15
In the "rotate" thread, there was mention that you can't chain filters with Animate(). I haven't tried, but can you use Animate() with a script function? If not, would it be difficult to implement?

Xesdeeni

WarpEnterprises
20th November 2002, 16:48
You can define a function (I suppose you call this a "script function") and call this function with Animate.

Try this and you get a sliding colour:

animate (1,100, "test",1,100)
return last

function test(int x) {
return stackHorizontal(BlankClip(height=100, width=100-x, color=$800000), BlankClip(height=100, width=x, color=$808000))
}

Wilbert
20th November 2002, 17:02
Some days ago I added some examples to animate.html, you might want to see that:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/avisynth2/avisynth/docs/filters/animate.html?
You can even apply animate to itself :)

AsTimeGoesBy
28th July 2005, 03:23
It seems there is a new Animate() link (http://www.avisynth.org/Animate) meanwhile...!?

However, I have my problem with it too:
To get some kind of widescreen impression i like black horizontal borders to flow in the video/frame and flow out at the end again:
- no borders until frame 16
- borders will appear line by line
- borders will remain from frame 112 till 160
- borders will disappear again
- no borders form frame 256 to the end


If possible, please could you tell me why this doesn't work correctly?

function addblack(clip,pad) {
clip = crop(clip,0,pad,800,600-(pad*2))
clip = addborders(clip,0,pad,0,pad)
return clip
}

imagereader("800x600.jpg",0,272,fps=25)

animate( 16,112,"addblack",0,96)
applyrange( 113,159,"addblack",96)
animate( 160,256,"addblack",96,0)
As video an image was used here. Please note with this example the source should be 800x600 pixels.

stickboy
28th July 2005, 07:42
From the docs:Animate is a meta-filter which evaluates its parameter filter with continuously varying arguments. At frame start_frame and earlier, filter is evaluated with the arguments given by start_args. At frame end_frame and later, filter is evaluated with the arguments given by end_args. In between, the arguments are linearly interpolated for a smooth transition.It's kind of confusing (it certainly wasn't what I expected), because start_frame and end_frame really represent the start/end of the transition area, but the filter actually affects the frames outside that range too. This means that the ApplyRange call isn't necessary.

So here's what you can do:a = animate(16, 112, "addblack", 0, 96)
b = animate(160, 256, "addblack", 96, 0)

a.Trim(0, 120) + b.Trim(121, 0)Also, you can simplify AddBlack to be:function AddBlack(clip clip, int pad)
{
return clip.Letterbox(pad, pad)
}

AsTimeGoesBy
28th July 2005, 11:00
Thanks for response!
It tooks a moment to understand there the value of 120 comes from...:
a.Trim(0, 120) + b.Trim(121, 0)
...then i have realized here it can be any value >(16+96) and <160 because the mal-functionality ignores ranges as you said.

In meantime i have found another 'solution' too, however it's not very elegant and looks quite schizofrenic:
function AddBlack(clip clip, int pad)
{
return clip.Letterbox(pad, pad)
}

imagereader("800x600.jpg",0,272,fps=25)

applyrange( 16,112, "animate", 16, 112, "addblack", 0, 96)
applyrange( 113,159, "AddBlack", 96)
applyrange( 160,256, "animate", 160, 256, "addblack", 96, 0)
As you see, AddBlack() is already updated with your version. I'm glad you were able to improve it by eleminating width and height!


But generally i'm not very happy with both approaches. They doesn't seem very logical to me...
And here is another problem - although i'm not sure if it depends on Animate() or crop():

# generating 360° movie:
clip = ImageReader("Animated-Beach.jpg", 0, 1519, 25, false)
Animate(0,1519,"Crop", clip,0,1,760,345, clip,1519,1,760,345)

# (temporal) filters...

# trim(10,1509)
Like this it works! - But if you take 'prettier' values...:
Animate(0,1519,"Crop", clip,0,8,760,344, clip,1519,8,760,344)
...the script results in an Avisynth read error. It happens with me with all cominations of VirtualDub 1.6.4, VirtualDumMod 1.5.10, AviSynth 2.5.5, AviSynth 2.5.6 Beta 3.
I will post the image once more hopping 'apreciate-factor' is > 'bothering-factor'. However there is a encoded version (http://people.ee.ethz.ch/~fhoesli/video/Feature-Test-DivX.2BVOP-GMC.('Private-Beach').avi) too.

Wilbert
31st July 2005, 13:06
1) What's the original size of your jpg?
2) Provide full script which doesn't work.

AsTimeGoesBy
31st July 2005, 14:32
1) What's the original size of your jpg?
2) Provide full script which doesn't work.Please check the attached beach image above, the context menu says it's 3000x346 pixels. ;)
It's just the same image as i have used in my script:

# generating 364.8° movie:
clip = ImageReader("Animated-Beach.jpg", 0, 1519, 25, false)

# This Animate()-Crop() command does not work:
Animate(0,1519,"Crop", clip,0,8,760,344, clip,1519,8,760,344)

# This Animate()-Crop() command would work:
# Animate(0,1519,"Crop", clip,0,1,760,345, clip,1519,1,760,345)

More is not needed to reproduce that access violation error again.

Wilbert
31st July 2005, 16:02
344+8>346 (760x344 is size of new clip). You try to crop to much. (Of course avs should throw an error, but it doesn't do that here.)

Try something like

# generating 364.8° movie:
clip = ImageReader("Animated-Beach.jpg", 0, 1519, 25, false)

# This Animate()-Crop() command does not work:
Animate(0,1519,"Crop", clip,0,2,760,344, clip,1519,2,760,344)

AsTimeGoesBy
31st July 2005, 17:47
Indeed! Now i see, crop() wants the new frame dimension/size.


I guess i have messed up height with the y-coodinate...

...damn! - Sorry for inconvenience.

trolltuning
3rd August 2005, 14:09
When I tried Warpenterprises script (just pasted it-no changes), I get an access violation after it plays 1/2 way.

Avisynth read error.
Avisynth: caught an access violation at 0 x100123e0,
attempting to read from 0xffffffff

darkavatar1470
7th August 2005, 18:06
Hi, I was trying to do a pan this way, and I think I stumbled over a bug.

I loaded a PNG file created by PhotoImpact 10, found it to be upside down, use FlipVertical(), but the first frame is still upside down. Here's the script used:

clip = ImageReader("p035_BG+Iria_001.png", 0, 199, 23.976, false)

clip2 = FlipVertical(clip)

Animate(0,199,"Crop", clip2,0,0,720,0, clip2,3184,0,720,0)


Funny is that after I finish encoding in VDM, first frame in the preview window is right side up, but the output file is still b0rked.

stickboy
7th August 2005, 19:08
The upside-down problem is a bug in ImageSource. I hear it's fixed in AviSynth 2.5.6.