video - FFmpeg concatenation, no Audio in Final Output -


i have following command working in ffmpeg, adds 1 second of black frame beginning of video. however, lose audio original video in output video. how can adjust command make sure original audio stays final output, or better yet, there 1 second of "blank" audio @ beginning matches new output video.

ffmpeg -i originalvideo -f lavfi -i color=c=black:s=1920x1080:r=25:sar=1/1 -filter_complex "[0:v] setpts=pts-startpts [main]; [1:v] trim=end=1,setpts=pts-startpts [pre]; [pre][main] concat=n=2:v=1:a=0 [out]" -map "[out]" finaloutputvideo.mp4 

you need generate or add audio associated black video because each concatenated section needs same number of video , audio streams.

ffmpeg \ -i originalvideo \ -f lavfi -i color=c=black:s=1920x1080:r=25:sar=1/1:d=1 \ -t 1 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 \ -filter_complex \ "[0:v]setpts=pts-startpts[mainv]; \  [0:a]asetpts=pts-startpts[maina]; \  [1:v][2:a][mainv][maina]concat=n=2:v=1:a=1[v][a]" \ -map "[v]" -map "[a]" -movflags +faststart output.mp4 
  • you can eliminate (a)setpts filters color , anullsrc source filters since timestamps start @ 0.

  • you can avoid trim filter because can set duration each filter.

  • the -t value anullsrc duration needs less or equal duration of black video: concat filter automatically pad rest silence.

  • with anullsrc ensure match proper channel layout , audio sample rate of main video; otherwise concat may automatically choose "common" layout , rate may not want.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -