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

2

5

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

Pennsylvania answered 8/1, 2016 at 5:29 Comment(4)
You can, but it's going to be one long command. Are all images the same size and to be at the same position?Cedrickceevah
yes. It will be the same size as the video and so will be positioned at the start i.e. 0,0Pennsylvania
@Mulvya what is the command?Memberg
Use the one by incBrain.Cedrickceevah
F
4

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
Fecundate answered 8/1, 2016 at 9:20 Comment(1)
Thank you so much!!! I''d been searching for this solutions for a while... Praise Jesus!!Bitty
G
3

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.

Gasiform answered 8/1, 2016 at 22:31 Comment(2)
how do you mean ordered sequence of images ?Pennsylvania
Currently I have 10 images sequentially named from 1..10 but the command did not display the images in that orderPennsylvania

© 2022 - 2024 — McMap. All rights reserved.