Log in

View Full Version : 2 Questions concerning Overlay+Timeline


IcedSoul
27th August 2013, 23:28
Hello,

i am trying to learn Avisynth at the moment, but have some difficulties to understand it.

First my sourcecode I am using:

video1=ChangeFPS(AviSource("D:\shipintro.avi", false),30).ConvertToYUY2
video2=ChangeFPS(AviSource("D:\bayarea.avi", false),30).ConvertToYUY2
video3=ChangeFPS(AviSource("D:\docking.avi", false),30).ConvertToYUY2
video=video1+video2+video3

clip = ChangeFPS(AviSource("D:\hail.avi",false),30).AddBorders(20,20,20,20,11110).BicubicResize(360,240).ConvertToYUY2
Overlay(video,clip,x=905,y=10,mode="blend", opacity=1.0)


So, I have some video snippets, and this small clip with a hail from the ship operator for docking to bay B-3-1.
It appears in the upper right corner and plays.

What I don't understand is:
1) why the place of the clip is staying black after playing the hail.avi?
I tried to nullify the clip with clip = BlankClip(length=200, pixel_type="yv12") at the end, but then, VirtualDub says the script returned no video... ?!?
2) why do any additions at the end of the script lead to ignoring the Overlay? I mean, Overlay() is before any other commands. if I add "video" at the end, Overlay() is ignored and no hail is played.
I fear that Avisynth is not really meant for video editing in this way, is it?
Or do I just understand Avisynth wrong?

I would really appreciate a small explanation.

raffriff42
28th August 2013, 04:11
> 1) why the place of the clip is staying black after playing the hail.avi?
So the overlay clip "hail.avi" is shorter than the base clip, and you are seeing a black square overlay after the end of hail.avi? I can't find any documentation (http://avisynth.nl/index.php/Overlay) for that scenario; it might be a feature and not a bug. If you want the overlay to go away, you would do something like this: video1=ChangeFPS(AviSource("D:\shipintro.avi", false),30).ConvertToYUY2
video2=ChangeFPS(AviSource("D:\bayarea.avi", false),30).ConvertToYUY2
video3=ChangeFPS(AviSource("D:\docking.avi", false),30).ConvertToYUY2
video=video1+video2+video3

clip = ChangeFPS(AviSource("D:\hail.avi",false),30)
\ .AddBorders(20,20,20,20,11110)
\ .BicubicResize(360,240).ConvertToYUY2

#Overlay(video,clip,x=905,y=10,mode="blend", opacity=1.0).Trim(0, clip.FrameCount)
#\ + video.Trim(clip.FrameCount+1, 0)
## EDIT - wrong! see below

Overlay(video,clip,x=905,y=10,mode="blend", opacity=1.0).Trim(0, clip.FrameCount-1)
\ + video.Trim(clip.FrameCount, 0)


EDIT - alternately, what about this (bonus, you can fade the overlay in & out)
video1=ChangeFPS(AviSource("D:\shipintro.avi", false),30).ConvertToYUY2
video2=ChangeFPS(AviSource("D:\bayarea.avi", false),30).ConvertToYUY2
video3=ChangeFPS(AviSource("D:\docking.avi", false),30).ConvertToYUY2
video=video1+video2+video3

clip = ChangeFPS(AviSource("D:\hail.avi",false),30)
\ .AddBorders(20,20,20,20,11110)
\ .BicubicResize(360,240).ConvertToYUY2

## make a "mask" clip (white=opaque, black=transparent)
M=BlankClip(clip, color=color_white).FadeOut(120) + BlankClip(clip, length=30000)
M=M.ColorYUV(levels="TV->PC")
Overlay(C, clip, mask=M)

Gavino
28th August 2013, 09:59
So the overlay clip "hail.avi" is shorter than the base clip, and you are seeing a black square overlay after the end of hail.avi? I can't find any documentation (http://avisynth.nl/index.php/Overlay) for that scenario; it might be a feature and not a bug.
Generally, filters that combine two clips of different lengths will extend the shorter clip by repeating its last frame. See here (http://avisynth.nl/index.php/Filters_with_multiple_input_clips) (although Overlay is missing from the table, it behaves like Layer). Presumably, the last frame of hail.avi is black.


Overlay(video,clip,x=905,y=10,mode="blend", opacity=1.0).Trim(0, clip.FrameCount)
\ + video.Trim(clip.FrameCount+1, 0)
Should be:

Overlay(video,clip,x=905,y=10,mode="blend", opacity=1.0).Trim(0, clip.FrameCount-1)
\ + video.Trim(clip.FrameCount, 0)

...
I tried to nullify the clip with clip = BlankClip(length=200, pixel_type="yv12") at the end, but then, VirtualDub says the script returned no video... ?!?
2) why do any additions at the end of the script lead to ignoring the Overlay? I mean, Overlay() is before any other commands. if I add "video" at the end, Overlay() is ignored and no hail is played.
The line Overlay(video,clip, ...) does not alter the variable 'video' - the result of the Overlay() is stored in the special variable last. If you add 'video' at the end, the original video will be returned and the result of the Overlay is ignored.
Similarly, if you add 'clip=...' as the last line, the script will return no video, since an assignment statement does not return a value.

See here (http://avisynth.nl/index.php/Grammar) and here (http://avisynth.nl/index.php/The_full_AviSynth_grammar#Statements) for more details.

raffriff42
28th August 2013, 13:07
Gavino, thank you once again.

IcedSoul
29th August 2013, 11:14
Many thanks, I'll try that this evening!

IcedSoul
29th August 2013, 18:55
Woo! That made it! Many thanks! I'm so happy!
Thanks for your great explanation Gavino!

I'm just at the beginning, I hope I can learn much more in the way I'm making the video.