0

I am trying to add a green screen video overlay on the top of my main video. The green video overlay is like a thumbs up that shows up every few minutes in the video. I have a ffmpeg command that adds the video overlay perfectly. (I got this from here)

ffmpeg -i input.mp4 -i green.mp4 -filter_complex     \
       '[1:v]colorkey=0x00ff00:0.4:0.2[ckout];[0:v][ckout]overlay[out]' \
        -map '[out]'  -c:v libx264 -pix_fmt yuv420p res.mp4

However, the green.mp4 show up right at the beginning. But I am trying to add it at a regular intervals. Say 5 minutes, 10 minutes, etc. Something like this.

overlay video at regular interval

I am even ok with just having it show up once in the video, but at the specified time. It would be nice to have it repeated few times, if possible, and not too complicated.

Destroy666
  • 12,350
DigitalNomad
  • 1,918

1 Answers1

0

Simply add proper enable property to the filter:

ffmpeg -i input.mp4 -i green.mp4 -filter_complex     \
  "[1:v]colorkey=0x00ff00:0.4:0.2[ckout];[0:v][ckout]overlay=enable='eq(mod(t, 300), 0)'[out]" \
  -map '[out]'  -c:v libx264 -pix_fmt yuv420p res.mp4
  • mod is used to check divisible intervals by comparing it to 0. You could instead compare to e.g. 1 (x) and use lt instead of eq to make the overlay appear for longer (x seconds).
  • 300 because 300 seconds = 5 minutes, so the interval

See documentation for enable and supported expressions.

Destroy666
  • 12,350