XOR Media

Extract a Video Clip on the Command-Line with avconv (ffmpeg)

If you want a quick and easy way to extract a clip from a larger video it doesn’t get much simplier than using avconv (the new ffmpeg.) All you need to know is the start time and duration of the section you’d like to extract. Once you have those you can plug them in to the following command.

avconv -ss <start-time> -t <duration> -i long-video.mp4 -codec copy funny-clip.mp4

If for example you’d like to take a 48 second clip starting at 32 minutes and 15 seconds you’d use the following.

avconv -ss 00:32:15 -t 00:00:48 -i long-video.mp4 -codec copy funny-clip.mp4

Of course you can use any of the conversion capabilities of avconv in the process, here we’re preserving the input codecs.

If you happen to be on an older system with ffmpeg the you’ll need to make a slight modification to the command and specify copy for both audio and video.

ffmpeg -ss 00:32:15 -t 00:00:48 -i long-video.mp4 -vcodec copy -acodec copy funny-clip.mp4