Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

ffmpeg how to trim x seconds from the start of a video

Written by John Riselvato - original link

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