How to connect filter complex in ffmpeg?

6,874

Use

ffmpeg -i input.mp4 -i %04d.png -i another_input.png -filter_complex "\
  [0]drawtext=text='Text to write':fontsize=180:fontcolor=white:x=500:y=800:enable='eq(n\,25)'[tmp];\
  [2:v]scale=20:20[ovrl];\
  [tmp][ovrl]overlay=860:500:enable='eq(n\,0)'[tmp1];\
  [tmp1][1:v]overlay=0:0" output.mp4
Share:
6,874

Related videos on Youtube

user1661677
Author by

user1661677

Updated on September 18, 2022

Comments

  • user1661677
    user1661677 almost 2 years

    I am running the following command with an error (also below):

    ffmpeg -i input.mp4 -i %04d.png -i another_input.png -filter_complex "\
      drawtext=text='Text to write':fontsize=180:fontcolor=white:x=500:y=800:enable='eq(n\,25)'[tmp];\
      [2:v]scale=20:20[ovrl];\
      [0:v][ovrl]overlay=860:500:enable='eq(n\,0)'[tmp];\
      [tmp][1:v]overlay=0:0" output.mp4
    

    I'm receiving an error Filter drawtext has a unconnected output

    I'm assuming this is where we move from the drawtext filter to the scale filter, but I'm not sure how to 'connect' the [tmp] to the scale filter while keeping drawtext first. Any help?

    • Gyan
      Gyan over 7 years
      On what do you want to draw the text upon? The final composite?
    • user1661677
      user1661677 over 7 years
      I'd like to draw the text on [0:v], output that to [tmp], then scale/overlay [2:v] onto [tmp]
  • user1661677
    user1661677 over 7 years
    Thank you. What is the reason I can't use [tmp] throughout?
  • Gyan
    Gyan over 7 years
    You could but it's not good practice to assign same label to different filterchain outputs. In any case, that's not the error in your command but that you assigned tmp as the output of two different filterchains, but did not feed the first to another filterchain before creating the second one. So it became ambiguous.