2

I have a video and a set of images (each image for one video frame) I want to overlay the images over the video, each image over one single frame. The images and the video have the same size. I know the number of video frames by fetching the metadata first.

Here is the command that I am running.

ffmpeg -y -i "video-file.mp4" -i "%05d.png" -filter_complex "[0:v][1:v]overlay" "output-video-file.mp4"

The issue is that the generated video is longer than the initial video because it hasn't yet overlayed all the images provided. It looks like each image has been overlayed over several frames so by the end of the video, there were still frames left and it overlayed them all over the last frame of the initial video.

What is missing from this command?

2
  • 1
    The PNG images have no timestamps, and getting the default 25fps frame rate. Try adding: -framerate 30 if the rate of video-file.mp4 is 30fps (for example). I think it's not going to work, because the overlay filter implementation is based on timestamps instead of frame numbers (and FFmpeg timestamps synchronization is not accurate enough).
    – Rotem
    Commented Jan 8 at 16:52
  • I've used -framerate option passing the video framerate and it seems to work. The generated video has the same size and it looks like all images have been overlayed. I can't be actually sure that each image was overlayed but I do notice that the first and last image is properly overlayed. Commented Jan 9 at 6:47

1 Answer 1

1

I needed to add the -framerate option with the framerate of the video. It has to come right before passing the sequence of images.

ffmpeg -y -i "video-file.mp4" -framerate 30 -i "%05d.png" -filter_complex "[0:v][1:v]overlay" "output-video-file.mp4"

You must log in to answer this question.

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