(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

Related Posts

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

Comments are closed.