How to concatenate two MP4 files using FFmpeg?

后端 未结 22 3063
遇见更好的自我
遇见更好的自我 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:20

    Detailed documentation on various ways of concatenation in ffmpeg can be found here.

    You can use 'Concat filter' for quick concatenation.

    It performs a re-encode. This option is best when inputs have different video/audio formats.

    For Concatenating 2 files:

    ffmpeg -i input1.mp4 -i input2.webm \
    -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" \
    -map "[v]" -map "[a]" output.mp4
    

    For Concatenating 3 files:

    ffmpeg -i input1.mp4 -i input2.webm -i input3.mp4 \
    -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] concat=n=3:v=1:a=1 [v] [a]" \
    -map "[v]" -map "[a]" output.mp4
    

    This works for same as well as multiple input file types.

提交回复
热议问题