FFMPEG- Is it possible to overlay multiple images over a video at specified intervals?

10,601

Basic method is

ffmpeg -i video -i image1 -i image2 -i image3
 -filter_complex
    "[0][1]overlay=x=X:y=Y:enable='between(t,23,27)'[v1];
     [v1][2]overlay=x=X:y=Y:enable='between(t,44,61)'[v2];
     [v2][3]overlay=x=X:y=Y:enable='gt(t,112)'[v3]"
-map "[v3]" -map 0:a  out.mp4

The last image will be overlaid from t=112 seconds till end of video.

Share:
10,601

Related videos on Youtube

hack
Author by

hack

Updated on January 15, 2020

Comments

  • hack
    hack over 2 years

    I want to overlay multiple images (Say 5) in a 120 second video at specified intervals , like, between 3-7 seconds overlay image 1. Is is it possible without splitting the video in multiple parts?

  • hack
    hack about 5 years
    Thanks. It is working. But there is a visible difference in quality of the video generated as output.
  • Gyan
    Gyan about 5 years
    Insert -crf 18 after the filter the complex. I assume you have libx264 in your ffmpeg build.
  • hack
    hack about 5 years
    if i have a single image to be overlapped at multiple intervals, will i have to specify it in input multiple times?
  • Gyan
    Gyan about 5 years
    No. Just reuse the same input pad e.g. [1].
  • hack
    hack about 5 years
    Hi. In this command, can we specify the input images to be overlayed in a text file? The final command getting generated is very very long. I have already put the complex filters in a script.
  • Gyan
    Gyan about 5 years
    It should be possible.
  • hack
    hack about 5 years
    Thanks. How to specify input pad in this case? Like i have 3 image path in a text file, how can we tell that overlay 1st image for these much seconds, 2nd for these seconds?
  • Sunny Tambi
    Sunny Tambi almost 5 years
    I am also doing the same, however my need is to be millisecond precise. There i find it hard to see precise timing in image overlay. Do you have any suggestion for me? Please see my post stackoverflow.com/questions/45818266/…
  • ND1010_
    ND1010_ about 4 years
    @Mulvya by using this command all images will appear 23 to 27(image1) after 27 second image1 disable and image2(44 to 61) enable and then disable at 61 sec and so on am i right? but in my case after showing first image other images can not visible
  • Gyan
    Gyan about 4 years
    Post a new Q with your full command and console output at SuperUser.
  • ND1010_
    ND1010_ about 4 years
    hey @Mulvya i have asked question Link[stackoverflow.com/questions/49363053/…
  • llogan
    llogan over 3 years
    Not much different than Gyan's answer.