How to splice sections of a video with avconv?

7,880

I believe you will have to cut separate chunks, then concatenate them. Don't use cat for that, as timecodes will be all over the place.

If the video chunks are mp4, use mp4box (from the gpac package) for concatenation:

mp4box -cat vid1.mp4 -cat vid2.mp4 ... -cat vidN.mp4 -new vid1-N.mp4
Share:
7,880

Related videos on Youtube

DisgruntledGoat
Author by

DisgruntledGoat

Updated on September 18, 2022

Comments

  • DisgruntledGoat
    DisgruntledGoat almost 2 years

    I have figured out so far that you can cut a section from a video with avconv with a command like this (cuts from 1:00-3:00):

    avconv -ss 00:01:00 -i "input.avi" -t 00:02:00 -c:v libx264 -crf 23 "output.mp4"
    

    But how would I cut two (or more) sections from the video and combine them into one video? For example, taking 1:00-3:00 as above, plus 8:00-10:00, making a final 4 minute video.

    I guess I can do them separately then concatenate them, but is there a simpler way?

    • Admin
      Admin almost 9 years
      Did you ever figure this out? I'm interested in doing exactly the same
    • Admin
      Admin almost 9 years
      @Benoir nope, sorry. But as per Janus' comment you may be able to first convert both videos to MPEG (at 100% quality), concatenate them, then re-encode in your desired format. I never bothered though...
  • DisgruntledGoat
    DisgruntledGoat over 11 years
    Simply concatenating files doesn't work for most video formats AFAIK...
  • Janus Troelsen
    Janus Troelsen almost 11 years
    @DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f
  • peterph
    peterph over 9 years
    Hardcoding file and directory names into a script is not necessary since positional parameters (and mktemp for temporary files created by the script) have been invented.