Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a divx video of 10 mins. I want to copy two parts from it , minutes 2 to 6 and 8 to 10 and create another video by merging the two. how can I do it using lightweight command line tools. Either on Windows or Linux?

share|improve this question
up vote 3 down vote accepted

Perhaps ffmpeg/mencoder (available on either platform).

To split:

ffmpeg -ss [start_seconds] -i [input_file] -t [duration_seconds] [outputfile]

For example:

ffmpeg -ss 2 -i input.avi -c copy -t 4 video1.avi
ffmpeg -ss 8 -i input.avi -c copy -t 2 video2.avi

To merge:

mencoder -ovc copy -oac copy video1.avi video2.avi -o output.avi

If your video/audio is out of synchronization, you might need to re-encode them, e.g. with XviD for an AVI container, and MP3 audio:

ffmpeg -ss 2 -i input.avi -c:v libxvid -qscale:v 3 -c:a libmp3lame -q:a 3 -t 2 output.avi

Change the qscale parameter to a lower value for higher quality, and the same for q:a for the audio parts.

share|improve this answer
does it work on divx encoded videos? let me check.. – iceman Nov 26 '09 at 20:20
small corrections ; -t duration' : Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[.xxx] syntax is also supported. -ss position' : Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported. Itried this and it worked but the video and the audio are time shifted and also there's a big difference in the original and output quality.The output's very degraded. DivX is a variant of MPEG4 hence we can ffmpeg as it can produce MPEG4 on its own – iceman Nov 26 '09 at 21:03
I left out the hh:mm:ss given the context of your answer. I admit, I tried this in a ssh connection to home. Didn't verify the quality. Perhaps try doing it all w/ mencoder? – basszero Nov 28 '09 at 14:35
the video and the audio are time shifted – iceman Dec 27 '09 at 9:01

To split the video there's a hand command line tool called jumptheshark.

share|improve this answer

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.