<p>You only have two inputs, so <code>2:v</code> 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. </p>

<pre><code>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'
</code></pre>

CC BY-SA 4.0
2022-09-08T12:18:02.683Z
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
Patel Milan
CC BY-SA 4.0
2019-01-14T17:31:13.050Z
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
CC BY-SA 4.0
2019-01-14T15:48:15.997Z
2019-01-14T15:48:15.997Z
Gyan
<p>I'm trying to figure out how this works, but I couldn't find the final solution.</p>

<pre><code>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'
</code></pre>

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

<hr>

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

<p><a href="https://stackoverflow.com/questions/47322739/ffmpeg-overlay-multiple-fading-texts-with-different-colors">https://stackoverflow.com/questions/47322739/ffmpeg-overlay-multiple-fading-texts-with-different-colors</a></p>

<hr>

<p><a href="https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos</a></p>

<hr>

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

<ffmpeg>
Add overlay video and animated text (textbox and shadow) with FFmpeg
Chili
# Add overlay video and animated text (textbox and shadow) with FFmpeg

(Asked by: username_0 on 2019-01-14)

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.

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2019-01-14. Score: 1 | Accepted answer

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'

> **Comments:**
> **username_0**: 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 @username_1!  
> **username_2**: Hello Mr. @username_1 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  

---

