Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to overlay an image on each frame of a video using FFMPEG

I am trying to overlay 10 different images on a 10 second video. I am currently able to overlay one image over the entire time span of the video using FFMPEG. I want to be able to see a different image every sec on the video.

How can i achieve this if it is possible?

Regards, Reuben

like image 606
ReubenCH Avatar asked Jan 08 '16 05:01

ReubenCH


2 Answers

Yes the command should then look similar to this:

ffmpeg -y 
  -i foo.mp4 -i foo.jpg -i bar.jpg [...put more pics here...]
  -filter_complex "
      [0:v][1:v] overlay=25:25:enable='between(t,0,1)' [tmp];
      [tmp][2:v] overlay=25:25:enable='between(t,1,2)' [tmp]
      ...continue the same way...
  " 
bar.mp4
like image 125
Dimitri Podborski Avatar answered Sep 27 '22 02:09

Dimitri Podborski


An easy method assuming you have an ordered sequence of images:

ffmpeg -i video.mp4 -pattern_type glob -framerate 1 -i "*.png" \
-filter_complex overlay output.mp4

The downside is that all input images need to be the same width, height, and pixel format: otherwise the overlaid frames may not display properly.

like image 37
llogan Avatar answered Sep 27 '22 02:09

llogan