0

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!

3
  • Are all videos the same resolution?
    – Gyan
    May 22, 2018 at 9:46
  • yes, all videos are in same resolution. May 22, 2018 at 11:22
  • @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? Dec 14, 2018 at 11:26

1 Answer 1

1

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.'
2
  • Thanks! your command is merged 3 videos but sound of second video is cut and also audio is not added in second video. May 23, 2018 at 10:00
  • 1
    Replace amerge=inputs=2 with amix=inputs=2:duration=shortest and remove pan filter.
    – Gyan
    May 23, 2018 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.