2

This is my scenario:

I want to add a watermark video in other video, but I want that the watermark starts when it appears.

Actually I'm able to display a watermark video and playing it from the beginning. If I try to add the watermark in a specific interval, it appears correctly in the period specified, but the watermark appears stopped because it starts when the main video is played.

This is the command that I'm using:

ffmpeg -y -i big_buck_bunny.mp4 -i alpha.mov -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov]; [0:v][ov] overlay=10:main_h-overlay_h-10:enable=between(t\,3\,5) [v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy out.mp4

Any help would be appreciated. Thank you

1
  • 1
    Welcome to super user. This question needs a bit of clarification. Particularly the statements "I want that the watermark starts when it appears" and " it is stopped because it starts when the main video is played." Welcome and good luck. Aug 8, 2014 at 16:59

1 Answer 1

5

Use -itsoffset just before the overlayed input with the same ammount of seconds you are using in the start of the filter (3 in your case)

This is maintaining the fade out filter you had, but that filter does not produce any visible results:

ffmpeg -y -i big_buck_bunny.mp4 -itsoffset 3 -i alpha.mov -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov]; [0:v][ov] overlay=10:main_h-overlay_h-10:enable=between(t\,3\,5) [v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy out.mp4

This is with 3 inputs (2 overlays and a base) and without that other filter:

ffmpeg -y -i basevideo.mp4 -itsoffset 3 -i overlay1.mp4 -itsoffset 8 -i overlay2.mp4 -filter_complex "[0:v][1:v] overlay=0:0:enable=between(t\,3\,5) [oa]; [oa][2:v] overlay=0:0:enable=between(t\,8\,10) [ob]"  -map "[ob]" -map 0:a -c:v libx264 -c:a copy output.mp4

To keep adding overlayed videos:

  • add -itsoffset **X** -i newinput.mp4 after last input file.
    • Order of input files is important
    • **X** is the time the overlay video will start playing (this will not show the overlay, just start internally the play of the video). Adjust it as neccesary (probably matching the value of **X** in the next step)
  • insert another [**previous_output**][**Y**:v] overlay=0:0:enable=between(t\,**X**\,**Z**) [**new_output**] after last block.
    • **Y** is the Yth input file, starting on 0 (in my example basevideo is 0, overlay1 is 1, overlay2 is 2, etc).
    • **X** is the time the overlay will show up in the output video.
    • **Z** is the time the overlay will hide in the output video.
    • Time is counted as for the start of the basevideo, not the lenght of the overlayed video, so do your calculations on duration: if the overlay video is 2 seconds long, **Z** will be **X** + 2.
  • Adjust the -map "[**XX**] at the end of the command to match the **new_output**, or you will be writing to file the previous step!

NOTE audio is grabbed directly from basevideo. The audios from the other sources are ignored and will not play at all.

2
  • Thank you! Can I ask you a suggest how to configure the command if I have more than one overlay?
    – stuzzo
    Aug 28, 2014 at 9:23
  • @stuzzo improved response
    – NuTTyX
    Aug 28, 2014 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .