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 an audio track

Written by John Riselvato - original link

Here we’ll use an input file with a 1 minute duration with a 5 second introduction of silence. To remove that silence, it’s important to identify these two numbers because trimming requires tricky subtraction. Let’s look at the example below:

$ ffmpeg -ss 00:00:10 -i input.mp3 -t 00:01:00 -async 1 output.mp3

-ss is used to seek to a part in the audio and -t is the duration of the playback. So 1 minute duration audio subtracted by 10 seconds seeking results in the first 10 seconds being removed.

A major setback with trimming is manually setting the audio duration value. Luckily, FFMPEG has a tool called ffprobe which can be used to give you exact duration:

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

Note: “How to Use FFMPEG in bash Language?” for ideas on how to use this output as a variable and dynamically set -t the advanced FFMPEG programming.