I am trying to overlay an input video with many images where each image should be shown for a short time. I achieved this using complex filter (the command below). The problem is that I have many, many images (>1000) :-)

ffmpeg -y -i in.mp4 

-i logo1.png 
-i logo2.png 
-i logo3.png 

-filter_complex "

[0:v][1:v] overlay=10:10:enable='between(n,2,4)'    [tmp]; 
[tmp][2:v] overlay=30:30:enable='between(n,6,8)'    [tmp]; 
[tmp][3:v] overlay=50:50:enable='between(n,10,12)'; 

" out.mp4 

Does FFmpeg allows a user to pass this data over a text-file ? The images are generated in memory, so pipes are also fine (in fact preferred).

(if that is not possible can I pass raw generated video in Bgra format ?; but I would not prefer this because the blend operation is more expensive + more IO: has to be as fast as possible)

Edit: If I use the following configuration, only the last sent image is overlayed.

-i ski.mp4 
-f image2pipe -vcodec png -i -

-filter_complex "[0:v][1:v] overlay=10:10:enable='between(n,2,3)' [tmp]; 
                 [tmp][1:v] overlay=30:30:enable='between(n,6,7)'"

-f mp4", "out.mp4"

FFmpeg outputs (it seems that it skips images if they have different sizes):

 Input stream #1:0 frame changed from size:1417x665 fmt:rgba to size:1800x700 fmt:rgba
 Input stream #1:0 frame changed from size:1800x700 fmt:rgba to size:550x371 fmt:rgba
 Input stream #1:0 frame changed from size:550x371 fmt:rgba to size:256x256 fmt:rgba

How can I instruct FFmpeg that for the first filter uses 1st image, for the second 2nd image in pipe, etc. (the images have different sizes) ?


If you can input your images as a sequence and specify your overlay x, y and time qualifiers as an expression, then this can be made as a manageable command.

You can input the images via pipe using the -f image2pipe -vcodec png as an input option.

Also, FFmpeg can reference a filterchain from a script

-filter_complex_script filename (global)

This option is similar to -filter_complex, the only difference is that its argument is the name of the file from which a complex filtergraph description is to be read.

  • Can you just point me out how to use the image2pipe properly regarding this question (see the edited answer above) ? (I have tried passing rgba video, that works, but it is too slow). Thank you again. – dajuric Mar 6 '16 at 1:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.