I'm trying to create an AviSynth script that replaces one shot in a video using one image.
How do I animate the position of the image so that it gradually moves down until it disappears offscreen? The image is also a uniquely shaped cut-out, so that it shows the video behind it along the edges of the frame.
Does anyone have a script example or tutorial I could take a look at?
+ Reply to Thread
Results 1 to 7 of 7
Take a look at these pages, they may have what you're looking for:
There are examples given on the animate page
It's also much easier to do in a video editor - you can control the speed /timing non linear movements much more easily. eg What if you want the speed to ramp up or down? Very difficult in avisynth - it's just linear interpolation
Here's my script:
LoadPlugin("C:\DVD\DGDecode.dll") clip1 = MPEG2Source("C:\DVD\01\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl5 = ImageSource("C:\Images\01.png", pixel_type="RGB32", start=0, end=77, fps=clip1.framerate) Animate(0, 77, "Crop", \ ovl5, 0, 0, 64, 32, \ ovl5, 316, 0, 64, 32) alpha_mask = ovl5.ShowAlpha() ovl5 = ovl5.ConvertToYV12() clip2.Trim(0,9) + clip2.Trim(0,2708)FadeOut(19) + clip1.Trim(2720,20002) + clip1.Trim(20003,20080).Overlay(ovl5) + clip1.Trim(20081,0)
If there is a partial white border, it might be your alpha channel isn't clean, or antialiasing, or your mask isn't using "full range", or it might be premultiplied alpha instead of straight, or color space issues
Not to discourage you, but it would be easier for other people to use a video editor. Much more control, easier and better for this type of task. Even if they wanted to use avisynth, they don't have your assets so how could they replicate it ?
If you wanted to post examples or "templates" for other people, you should include source material, for example sample images or videos to play with, maybe even a gif preview or video preview - so they can see how it works and play with the code.
Anyways what do you think is supposed to be happening here? Do you have a static image with embedded alpha channel as an overlay panning ? (ie. an animated transparent overlay or a static image?) . I didn't look at your code closely but it looks like your overlay syntax is problematic - Overlay(ovl5) doesn't specify an overlay clip. You have an alpha mask, but don't use it.
The way most people would do this in avisynth (or any panning motion) is animate the resize. Because resize has an offset crop value
Here is a hard example, with all assets
baseclip=BlankClip(length=100, width=640, height=480, fps=24, color=color_green).ShowFrameNumber() arrow=ImageSource("1.png", start=0, end=99, fps=24, pixel_type="RGB32") anim_arrow=Animate(arrow, 0, 47, "Spline36Resize", 640,480,0,0,0,0, 640,480,0,-480,0,-480) Overlay(baseclip, anim_arrow, mask=anim_arrow.showalpha())
Note the animate ends at 47, but the arrow is "off" at 43, because the layer is 640,480 with the origin at 0,0 (the arrow isn't at 0,0, the layer is at 0,0) . I didn't bother timing it to specific frames
There are probably several different ways you could do this in avisynth, all of them 10x more difficult to do than in an editor you you would just drag the arrow, start and end, adjust the velocity curve (keyframe interpolation). Avisynth is great for some tasks. Other tasks... not so much. This type of task falls into the "not so much" category . What if you wanted the arrow to speed up, or slow down? Ease in/out. Or curve and bend and point at an object? Very difficult to manipulate real animation in avisynth.
Last edited by poisondeathray; 11th Sep 2015 at 19:12.
I'm not sure what you mean about ovl5 though. I thought this was the clip over which I specified the overlay: 20003,20080.
Thanks again. Everything works great. Here's my result for the record:
LoadPlugin("C:\DVD\DGDecode.dll") clip1 = MPEG2Source("C:\DVD\01\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl5 = ImageSource("C:\Images\01.png", pixel_type="RGB32", start=0, end=78, fps=clip1.framerate) ovl5 = Animate(ovl5, 48, 78, "Spline36Resize", 720,480,0,0,0,0, 720,480,0,-480,0,-480) alpha_mask = ovl5.ShowAlpha() clip2.Trim(0,9) + clip2.Trim(0,2708)FadeOut(19) + clip1.Trim(2720,20002) + clip1.Trim(20003,20080).Overlay(ovl5, mask=alpha_mask) + clip1.Trim(20081,0)
You would upload the project file with the assets. e.g. you can use a free editor like aviutl .
aviutl can load avs scripts too (but not "live" editing of scripts, sort of like vdub. The .avs script "looks" like uncompressed video to aviutl). So you can combine avisynth with a video editor
The point of examples, is to learn from them, adapt them so you can apply to your own projects. But making changes , such as changing animation timing, or customizing the motion, changing assets, adding multiple layers etc.. those types of edits regarding any type of animation of layers are much easier to do in a video editor . To put it bluntly - control over animating layers is terrible in avisynth . A GUI is easier to use for most people for these types of tasks. Yes, avisynth excels at other types of tasks, but not for animation