1

Here is what I am trying to accomplish in one FFmpeg process:

  • A. Take in 3 inputs

  • B. Overlay input 1 over input 0 (input 1 has an alpha channel)

  • C. Take the result of step B and concatenate input 3 at the end

Reading up on the documentation I was able to accomplish B and C independently, but when I try chaining them together into a complex filter I can accomplish overlaying input 0-1 but the concatenation does not seem to work.

What it does is just freezing frame on the end of the overlaid clip, for the duration of input 3. In other words the output file has the correct duration, but instead of seeing input 3 at the end I just get a frozen frame at the end of input 2. Hopefully that is clear...

Here is the command I am using:

-loop 1 -r 29.97 -i input0.png -r 29.97 -i input1_%04d.png -i input2.mov \
    -c:v libx264 -crf 18 -filter_complex "[0][1]overlay=shortest=1;[1][2]concat=n=2:v=1" 
     output.mov

I believe I am close enough, so hopefully this is just a simple tweak!

3

You have to add a pad with a label to the result of the overlay and feed that to concat. The [1] fed to concat refers to the source frames of the image sequence. And since the overlay result isn't labelled. It is included as the first output stream, with the wrong concat result being the 2nd.

Use

-loop 1 -framerate 30000/1001 -i input0.png
        -framerate 30000/1001 -i input1_%04d.png
                              -i input2.mov
-filter_complex "[0][1]overlay=shortest=1[ovl];[ovl][2]concat=n=2:v=1"
-c:v libx264 -crf 18 output.mov

See http://ffmpeg.org/ffmpeg-filters.html#Filtergraph-description and http://ffmpeg.org/ffmpeg.html#Stream-selection

| improve this answer | |
  • Thanks a bunch Gyan, this is just what I needed. – Spencer Sep 8 '19 at 20:03
  • 1
    @Spencer You need to think of [0] and [1] as variables, which must be sent to another variable if you run a filter on them then want to run further filters on the result. Gyan named that variable [ov1]. FFmpeg needs to be able to reference the output of any used filter if you want to run other filters on it, otherwise it will try to send it directly into the output file. – user24601 Sep 10 '19 at 0:17
  • @DigiVisionMedia thanks, makes sense – Spencer Sep 11 '19 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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