Trimming Video with FFMPEG


One of the most common video editing needs is trimming a video — removing extraneous material that was recorded before or after the subject of the video. For example, in a recording of a presentation you might want to trim the beginning so that the speaker’s voice begins a second or two after the video starts, or trim the end to eliminate extra material after the speaker has finished.

There are many tools for doing these sorts of tasks. I used to use Windows Movie Maker, but that’s no longer bundled with Windows, and it’s also a low-quality option because it would re-encode the video after these sorts of edits. So in this post I’m going to explain how to trim a video with ffmpeg, the popular command-line tool for processing video files. As I’ve written about before, ffmpeg is a great tool for creating time-lapse videos, but that’s just one of hundreds of things you can do with it. One nice thing about using ffmpeg for video processing is that it works exactly the same on Windows, Mac, or Linux, so you can learn it once and then use it anywhere.

The first step is to install ffmpeg. Go to the ffmpeg download page and select your operating system, and you’ll find options for installing source code or binaries. If you just want to use ffmpeg and don’t have unusual codec requirements or a desire to share libraries or work with the source code, the version you’ll want to install is the static binary for your platform. On Windows, this option will give you a few standalone EXE files, probably packaged in a ZIP container. Extract ffmpeg.exe, and either put it in the folder where you’ll be working or something in your search path.

Ffmpeg is a command-line tool, so the next step is to go to a command prompt and navigate to the folder that contains your video file. You’ll also need to watch your video to determine where to start copying it, and how much to copy. In the example below, I have a video file named inputfile.mp4, and I want to extract a 22-minute section of it that begins 5 minutes after the start of the video, then write that extracted portion to a file named outfile.mp4. Here’s the command to do exactly that:


Note that I’ve specified a “copy” for the codec. That tells ffmpeg to simply copy the desired section of video, without re-encoding it. This keeps the quality as high as the original, with no degradation.

One other quirk to note is that the duration is specified with -t, which stands for transcode duration. Ffmpeg has more command-line options than there are letters in the alphabet, so some of the abbreviations are not very intuitive.

That’s all there is to it! Ffmpeg is a great tool for these sorts of tasks: cross-platform, very flexible, and it runs extremely fast.


Leave A Reply