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: shadowcolor=black@0.6:shadowx=4:shadowy=2: \
box=1: boxcolor=a60000@0.4: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.

0

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: shadowcolor=black@0.6:shadowx=4:shadowy=2: \
box=1: boxcolor=a60000@0.4: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'
  • 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 at 17:31

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.