Cut multiple videos and merge with ffmpeg

后端 未结 2 1903
梦谈多话
梦谈多话 2021-02-06 05:50

How can I cut a video into multiple parts and then join them together to make a new video with ffmpeg?

2条回答
  •  野的像风
    2021-02-06 06:42

    You question is quiet general...
    The following example may help you, but it might not solve your specific issues.

    The example applies three stages:

    • Create synthetic video (with no audio):

      ffmpeg -f lavfi -i testsrc=duration=3:size=160x120:rate=10 -c:v rawvideo -pix_fmt rgb24 testsrc.avi
      

      (The created video is uncompressed).
      Reference: https://trac.ffmpeg.org/wiki/FilteringGuide

    • Cut video into 3 parts (creating 3 video files):

      ffmpeg -i testsrc.avi -ss 00:00:00 -c copy -t 00:00:01 sec0.avi
      ffmpeg -i testsrc.avi -ss 00:00:01 -c copy -t 00:00:01 sec1.avi
      ffmpeg -i testsrc.avi -ss 00:00:02 -c copy -t 00:00:01 sec2.avi
      

      Reference: https://superuser.com/questions/138331/using-ffmpeg-to-cut-up-video

    • Concatenate (merge) 3 parts in reverse order:

      ffmpeg -i "concat:sec2.avi|sec1.avi|sec0.avi" -codec copy output.avi
      

      Note: for Linux use single quotes '
      Reference: Concatenate two mp4 files using ffmpeg

    Synthetic video looks as the following image:

提交回复
热议问题