0

I'm trying to figure out how this works, but I couldn't find the final solution.

ffmpeg -i input -i overlayvideo \
-filter_complex \
"[0:v] setpts=PTS-STARTPTS [v01]; \
[1:v] setpts=PTS-STARTPTS [gradient]; \
[2:v] drawtext=fontfile=...font.ttf: text='Test': fontcolor=white:fontsize=54: [email protected]:shadowx=4:shadowy=2: \
box=1: [email protected]:boxborderw=10:x='310':y='350',format=yuva444p,fade=t=in:st=1:d=1:alpha=1,fade=t=out:st=7:d=1:alpha=1, setpts=PTS-STARTPTS[v1][txt]; \
[v01][gradient] overlay [v02]; \
[v02][txt] overlay=[outv]" \
-c:v libx264 -profile:v main -level:v 3.1 -pix_fmt yuv420p -c:a aac -map [outv] \
-f mp4 -y 'output.mp4'

The error message: No output pad can be associated to link label 'txt'. Error initializing complex filters. Invalid argument*


I've studied these solutions, but for the time being, I don't understand where I made the mistake.

https://stackoverflow.com/questions/47322739/ffmpeg-overlay-multiple-fading-texts-with-different-colors


https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos


What have I forgotten why the output is not good? Thank you for your advice and help.

1 Answer 1

1

You only have two inputs, so 2:v can't exist. Instead, you'll need a base canvas to draw the text upon. I've used the color source filter for that. And you probably want that canvas to be the same size as the video. I've used scale2ref for that.

ffmpeg -i input -i overlayvideo \
-filter_complex \
"[0:v] setpts=PTS-STARTPTS [v01]; \
[1:v] setpts=PTS-STARTPTS [gradient]; \
color=black@0:duration=8,format=yuva444p[txtbase];[txtbase][v01]scale2ref[txtbase][v01];[txtbase] drawtext=fontfile=...font.ttf: text='Test': fontcolor=white:fontsize=54: [email protected]:shadowx=4:shadowy=2: \
box=1: [email protected]:boxborderw=10:x='310':y='350',fade=t=in:st=1:d=1:alpha=1,fade=t=out:st=7:d=1:alpha=1[txt]; \
[v01][gradient] overlay [v02]; \
[v02][txt] overlay[outv]" \
-c:v libx264 -profile:v main -level:v 3.1 -pix_fmt yuv420p -c:a aac -map [outv] \
-f mp4 -y 'output.mp4'
2
  • I've added -map 0:a because I want to use sound of main (input) video file. The timing of the text is still mysterious, but I'll keep under testing. Otherwise it works well, thanks @Gyan!
    – Chili
    Jan 14, 2019 at 17:31
  • Hello Mr. @Gyan I am using this command to overlay into videos ffmpeg -y -i input.mp4 -i overlay.png -filter_complex overlay=0:0 -strict -2 -c:a copy -flags +global_header -qscale:v 3 output.mp4 When sending on iphone the audio is muted problem give the solution regarding this command Thank you Sep 8, 2022 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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