Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T12:42:11.143Z
Answers.Text: this command works but voice is disabled. so how to enable audio?
Answers.UserDisplayName: Jinal Somaiya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T13:25:19.047Z
Answers.Text: 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?
Answers.UserDisplayName: Jinal Somaiya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T13:49:52.677Z
Answers.Text: 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
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T13:45:34.340Z
Answers.LastActivityDate: 2018-05-11T12:50:20.683Z
Answers.LastEditDate: 2018-05-11T12:50:20.683Z
Answers.UserDisplayName: Gyan
Body: <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>
  
Tags: <ffmpeg>
Title: how to set duration, fading start time and end time video wise in below command?
UserDisplayName: Jinal Somaiya
ThreadText: # 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  
  
  ---
  
  