Search code examples
videovideo-processingavisynth

Avisynth - Add image to video for X amount of frame then remove image


Total nooby Avisynth question. I'm trying to add an image at a set point in a video then remove it at a set point.

Eg. Video starts, then plays for 100 frames, then image is visible for 200 frames in top right corner of initial video, then disappears for remaining 100 frame of the initial video.

I know its something like the Layer or Overlay function but I just cant figure out how to apply the image at a set point rather than just the start of the initial video.

So for I've got this.

clip_black  = BlankClip(2000, 400, 400)

clip_team_one = ImageSource("C:\Users\Testing\Desktop\fun.png",  fps = 29.97,  end = 300).fadeio(28).converttoRGB32

clip1 = Layer(clip_black, clip_team_one, "add", 257 , 30, 20)

clip1

Solution

  • Use trim(start_frame, end_frame) or trim(start_frame, -number_of_frames).

    In your case, you'll need to replace the second-to-last line of script with something like:

    clip1 = clip_black.trim(0,-100) + Layer(clip_black.trim(100,-200), clip_team_one, "add", 257 , 30, 20) + clip_black.trim(100+200,0)
    

    You'll also need to change duration of your clip_team_one to 200 frames instead of 300.

    I'm not sure I understood you correctly about "disappear for 100 remaining frames" however, given the source video length of 2000 frames.

    More info about Trim here: http://avisynth.nl/index.php/Trim