FFmpeg Audio Trim – How to Trim Audio Files Using Start and Stop Times

audioffmpegtrim

I have an FFmpeg command to trim audio:

ffmpeg -ss 01:43:46 -t 00:00:44.30 -i input.mp3 output.mp3

The problem I have with this command is that option -t requires a duration (in seconds) from 01:43:46. I want to trim audio using start/stop times, e.g. between 01:43:46 and 00:01:45.02.

Is this possible?

Best Answer

ffmpeg seems to have a new option -to in the documentation:

-to position (input/output)
Stop writing the output or reading the input at position. position must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.

-to and -t are mutually exclusive and -t has priority.

Sample command with two time formats

ffmpeg -i file.mkv -ss 20 -to 40 -c copy file-2.mkv
ffmpeg -i file.mkv -ss 00:00:20 -to 00:00:40 -c copy file-2.mkv

This should create a copy (file-2.mkv) of file.mkv from the 20 second mark to the 40 second mark.

Related Question