XOR Media

Coding, Operations, Etc.

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

Posted on Wed 16 May 2012 by

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
In misc, tagged: command-line, linux, and video.

About the Author

Ross McFarland Ross McFarland | | |

Ross is a 17 year veteran of the software industry with experience spanning low-level signal processing, web and mobile user interfaces, high-scale distributed web services, infrastructure, and networking. He has made extensive contributions to open source highlighted by his time as a primary maintainer of Gtk2-Perl and author of requests-futures and python-asynchttp libraries. (more)