<p>Your fade out timings are one second too late - the fade out should start at 9 seconds of each clip so that it can end by 10 seconds.</p>

<pre><code>ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]" \
-vcodec libx264 -map '[outv]' merge.mp4
</code></pre>

<hr>

<p>If you have audio as well in the 3 files, use</p>

<pre><code>ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]; \
 [0][1][2]concat=n=3:v=0:a=1[outa]" \
-vcodec libx264 -map '[outv]' -map '[outa]' merge.mp4
</code></pre>

<p>This command assumes that all 3 files have 10 seconds of audio each, eolse sync will be lost.</p>

CC BY-SA 4.0
2018-05-11T12:42:11.143Z
this command works but voice is disabled. so how to enable audio?
Jinal Somaiya
CC BY-SA 4.0
2018-05-11T13:25:19.047Z
How to know video file has audio? we will have with audio and without audio so which command do you think is best for this purpose?
Jinal Somaiya
CC BY-SA 4.0
2018-05-11T13:49:52.677Z
Run `ffprobe -v 0 -select_streams a -show_entries stream=index -of compact=p=0:nk=1 "$file" | wc -l` . If it's zero, no audio in $file
Gyan
CC BY-SA 4.0
2018-05-10T13:45:34.340Z
2018-05-11T12:50:20.683Z
2018-05-11T12:50:20.683Z
Gyan
<pre><code>ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3:v]trim=duration=30[over]; \
 [over][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]" \
-vcodec libx264 -map '[outv]' merge.mp4
</code></pre>

<ffmpeg>
how to set duration, fading start time and end time video wise in below command?
Jinal Somaiya
# how to set duration, fading start time and end time video wise in below command?

(Asked by: username_0 on 2018-05-10)

ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3:v]trim=duration=30[over]; \
 [over][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]" \
-vcodec libx264 -map '[outv]' merge.mp4

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-05-10. Score: 0 | Accepted answer

Your fade out timings are one second too late - the fade out should start at 9 seconds of each clip so that it can end by 10 seconds.
ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]" \
-vcodec libx264 -map '[outv]' merge.mp4


If you have audio as well in the 3 files, use
ffmpeg -y -i intro.mp4 -i video.mp4  -i outro.mp4 -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS[v0]; \
 [1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[v1]; \
 [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS+20/TB[v2]; \
 [3][v0]overlay[over1]; \
 [over1][v1]overlay[over2]; \
 [over2][v2]overlay=format=yuv420[outv]; \
 [0][1][2]concat=n=3:v=0:a=1[outa]" \
-vcodec libx264 -map '[outv]' -map '[outa]' merge.mp4

This command assumes that all 3 files have 10 seconds of audio each, eolse sync will be lost.

> **Comments:**
> **username_0**: this command works but voice is disabled. so how to enable audio?  
> **username_0**: How to know video file has audio? we will have with audio and without audio so which command do you think is best for this purpose?  
> **username_1**: Run `ffprobe -v 0 -select_streams a -show_entries stream=index -of compact=p=0:nk=1 "$file" | wc -l` . If it's zero, no audio in $file  

---

