(FFmpeg) How to Trim ‘x’ Seconds From the Start of a Video?

Trimming a few seconds, minutes or hours from a video is simple but requires an understanding of the seeking and duration options.

In this example, the input file is 5 minutes long with a 15 second introduction that needs to be removed. It’s important to identify these two numbers because trimming requires tricky subtraction. Let’s look at the following example:

 $ ffmpeg -ss 00:00:15 -i input.mp4 -t 00:05:00 -async 1 output.mp4   

As outlined, -ss is used to seek to a part in the video and -t is the duration of the playback. A 5 minute long video subtracted by 15 seconds of seeking results in the first 15 seconds being removed.

A major setback with trimming is manually setting the video duration value. Luckily, FFmpeg has a tool called ffprobe which can be used output an exact duration:

  $ ffprobe -i input.mp4 -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal 

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon

Trackbacks & Pingbacks 2

  1. From (FFmpeg) How to Trim ‘x’ Seconds From the Start and End of a Video? - John Riselvato on 17 Apr 2020 at 1:04 pm

    […] last two questions covered trimming the start of a video and trimming the end of a video, but what does the […]

  2. From (FFmpeg) How to extract screenshots from multiple parts of a video? - John Riselvato on 28 Apr 2020 at 1:21 pm

    […] to clarify, the user was having issues understanding how to chain multiple seeking (-ss) with one input to get random frames from the video. This is possible in a couple of ways. First […]