How to concatenate two MP4 files using FFmpeg?

后端 未结 22 2960
遇见更好的自我
遇见更好的自我 2020-11-22 02:32

I\'m trying to concatenate two mp4 files using ffmpeg. I need this to be an automatic process hence why I chose ffmpeg. I\'m converting the two files into .ts files and th

22条回答
  •  有刺的猬
    2020-11-22 03:26

    Here's a fast (takes less than 1 minute) and lossless way to do this without needing intermediate files:

    ls Movie_Part_1.mp4 Movie_Part_2.mp4 | \
    perl -ne 'print "file $_"' | \
    ffmpeg -f concat -i - -c copy Movie_Joined.mp4
    

    The "ls" contains the files to join The "perl" creates the concatenation file on-the-fly into a pipe The "-i -" part tells ffmpeg to read from the pipe

    (note - my files had no spaces or weird stuff in them - you'll need appropriate shell-escaping if you want to do this idea with "hard" files).

提交回复
热议问题