Index RSS

Cutting a video with ffmpeg

I rarely have reason to get involved in some video editing. This means that the few use cases always have enough time in-between that I need to research how to do them again and again ... To change that, I will now describe how to extract a part of a video into its own video file, using ffmpeg.

Let's say that we want to get the part starting at 1 minute and 37 seconds to a little bit over 2 minutes and 17 seconds from our input.mp4 and save it as a new output.mp4. You can do it like this:

ffmpeg -ss 00:01:37 -to 00:02:17.5 -i input.mp4 output.mp4

If it is simpler to think in duration instead of finding the exact end time, this is possible via -t instead of -to:

ffmpeg -ss 00:01:37 -t 30.5 -i input.mp4 output.mp4

While doing so, you can mix and match file formats freely. If you use an audio format like mp3 or ogg as the output format, you will get just the audio data.