Answers.Body: <p>Use</p>
  
  <pre><code>ffmpeg -y -i intro.mp4 -i mainvideo.mp4 -i outro.mp4 -i EnergyAudio.mp3 \
         -i vcs-watermark-video.png \
         -filter_complex \
  "[0:v]drawtext=...,fade=t=out:st=5:d=1,setpts=PTS-STARTPTS[v0]; \
   [1:v][4]overlay=W-w-5:H-h-5,fade=t=in:st=0:d=1,fade=t=out:st=31:d=1,setpts=PTS-STARTPTS[v1]; \
   [2:v]fade=t=in:st=0:d=1,setpts=PTS-STARTPTS[v2]; \
   [3:a]volume=enable='between(t,0,32)':volume=-10dB[3a];[1:a][3a]amerge=inputs=2,pan=stereo[maina]; \
   [v0][0][v1][maina][v2][2]concat=n=3:v=1:a=1[outv][outa]" \
         -vcodec libx264 -c:a aac -ac 2 -map "[outv]" -map "[outa]" '.$fileName.'
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-23T10:00:16.630Z
Answers.Text: Thanks! your command is merged 3 videos but sound of second video is cut and also audio is not added in second video.
Answers.UserDisplayName: Jinal Somaiya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-23T10:18:36.533Z
Answers.Text: Replace `amerge=inputs=2` with `amix=inputs=2:duration=shortest` and remove pan filter.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-22T15:03:20.187Z
Answers.LastActivityDate: 2018-05-22T15:03:20.187Z
Answers.UserDisplayName: Gyan
Body: <p>I have four commands that is working perfectly but i want only one command to do this task.</p>
  
  <p><strong>Commands:</strong></p>
  
  <pre><code>ffmpeg -i ' . config('medialibrary.s3.domain') . '/listing_video/intro.mp4' . ' -vf "drawtext=fontfile=' . storage_path('assets/video/FutuMd.ttf') . ': text=' . $this-&gt;listing-&gt;car-&gt;name . ': x=300: y=450: fontsize=40: fontcolor=white: enable='between(t,2,5)'" introfinal.mp4
  
  ffmpeg -i mainvideo.mp4 -i '.config('medialibrary.s3.domain').'/listing_video/EnergyAudio.mp3'.' -filter_complex "[1:a]volume=enable='between(t,0,32)':volume=-10dB[1a];[0:a][1a]amerge=inputs=2[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -ac 2 -shortest mainvideooutput.mp4
  
  ffmpeg -i mainvideooutput.mp4 -i ' . storage_path('assets/image/vcs-watermark-video.png') . ' -filter_complex "overlay=main_w-overlay_w-5:main_h-overlay_h-5" -codec:a copy mainvideofinal.mp4
  
  ffmpeg -y -i introfinal.mp4 -i mainvideofinal.mp4  -i ' . config('medialibrary.s3.domain') . '/listing_video/outro.mp4' . ' -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
  "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=5: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=31:d=1:alpha=1,setpts=PTS-STARTPTS+6/TB[v1]; \
  [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+38/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]" '.$fileName.'
  </code></pre>
  
  <p>Thanks in advance!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-22T09:46:07.997Z
Comments.Text: Are all videos the same resolution?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-22T11:22:01.093Z
Comments.Text: yes, all videos are in same resolution.
Comments.UserDisplayName: Jinal Somaiya
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-14T11:26:44.673Z
Comments.Text: @Gyan in your answer after answer command runs new video created but audio of second video is cut after some time like last 8 seconds of second video audio is mute why?
Comments.UserDisplayName: Jinal Somaiya
Tags: <ffmpeg>
Title: Add text to first video, add audio and watermark to second video and then add crossfading to these two videos and one another video using one command?
UserDisplayName: Jinal Somaiya
ThreadText: # Add text to first video, add audio and watermark to second video and then add crossfading to these two videos and one another video using one command?
  
  (Asked by: username_0 on 2018-05-22)
  
  I have four commands that is working perfectly but i want only one command to do this task.
  
  **Commands:**
  
  ```
  ffmpeg -i ' . config('medialibrary.s3.domain') . '/listing_video/intro.mp4' . ' -vf "drawtext=fontfile=' . storage_path('assets/video/FutuMd.ttf') . ': text=' . $this->listing->car->name . ': x=300: y=450: fontsize=40: fontcolor=white: enable='between(t,2,5)'" introfinal.mp4
  
  ffmpeg -i mainvideo.mp4 -i '.config('medialibrary.s3.domain').'/listing_video/EnergyAudio.mp3'.' -filter_complex "[1:a]volume=enable='between(t,0,32)':volume=-10dB[1a];[0:a][1a]amerge=inputs=2[a]" -map 0:v -map "[a]" -c:v copy -c:a aac -ac 2 -shortest mainvideooutput.mp4
  
  ffmpeg -i mainvideooutput.mp4 -i ' . storage_path('assets/image/vcs-watermark-video.png') . ' -filter_complex "overlay=main_w-overlay_w-5:main_h-overlay_h-5" -codec:a copy mainvideofinal.mp4
  
  ffmpeg -y -i introfinal.mp4 -i mainvideofinal.mp4  -i ' . config('medialibrary.s3.domain') . '/listing_video/outro.mp4' . ' -f lavfi -i color=black:s=1280x720:d=30 -filter_complex \
  "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=5: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=31:d=1:alpha=1,setpts=PTS-STARTPTS+6/TB[v1]; \
  [2:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+38/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]" '.$fileName.'
  
  ```
  
  Thanks in advance!
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Are all videos the same resolution?  
  > **username_0**: yes, all videos are in same resolution.  
  > **username_0**: @username_1 in your answer after answer command runs new video created but audio of second video is cut after some time like last 8 seconds of second video audio is mute why?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-22. Score: 1 | Accepted answer
  
  Use
  
  ```
  ffmpeg -y -i intro.mp4 -i mainvideo.mp4 -i outro.mp4 -i EnergyAudio.mp3 \
         -i vcs-watermark-video.png \
         -filter_complex \
  "[0:v]drawtext=...,fade=t=out:st=5:d=1,setpts=PTS-STARTPTS[v0]; \
   [1:v][4]overlay=W-w-5:H-h-5,fade=t=in:st=0:d=1,fade=t=out:st=31:d=1,setpts=PTS-STARTPTS[v1]; \
   [2:v]fade=t=in:st=0:d=1,setpts=PTS-STARTPTS[v2]; \
   [3:a]volume=enable='between(t,0,32)':volume=-10dB[3a];[1:a][3a]amerge=inputs=2,pan=stereo[maina]; \
   [v0][0][v1][maina][v2][2]concat=n=3:v=1:a=1[outv][outa]" \
         -vcodec libx264 -c:a aac -ac 2 -map "[outv]" -map "[outa]" '.$fileName.'
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks! your command is merged 3 videos but sound of second video is cut and also audio is not added in second video.  
  > **username_1**: Replace `amerge=inputs=2` with `amix=inputs=2:duration=shortest` and remove pan filter.  
  
  ---
  
  