Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

For combining videos use:

cat video1 video2 > video3

Click here for more info.

If you would like to use the combined video in website, you could try a new technology, called popcorn.js. You should see this video to understand how to combine multiple videos without any software and to start any video from wanted seconds. It's very interesting.

For the whole process of cutting and combining videos maybe you need a script like this:

#! /bin/bash

cd $folder

avconv -ss 00:01:00 -t 00:02:00 -i $input -c:v libx264 -crf 23 $out1
avconv -ss 00:08:00 -t 00:10:00 -i $input -c:v libx264 -crf 23 $out2
# add as many lines as you like

cat $out1 $out2 > $combine

You only have to change the names of variables at the start of the script.

Also You could try MENCODER for joining videos:

mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi
share|improve this answer
Simply concatenating files doesn't work for most video formats AFAIK... –  DisgruntledGoat Nov 20 '12 at 0:16
@DisgruntledGoat: Correct. Only works for MPEG-1, MPEG-2 PS, DV: ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f –  Janus Troelsen Jul 25 '13 at 11:40
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. –  peterph Oct 10 '14 at 18:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.