FFMPEG cut for time range

7

2

I am using below command for having 15sec - 45 sec range of music but sample.m4a file is starting from 15 sec to 60 sec. Am i using wrong syntax or why it is so ?

ffmpeg -ss 00:00:15 -t 00:00:45 -i song.m4a -acodec copy sample.m4a

Freshblood

Posted 2014-05-26T14:49:25.933

Reputation: 389

Answers

16

The -t flag sets duration.
So in case you want 15sec-45sec range you must set -t 00:00:30 (i.e. 45-15=30) and use -t parameter after filename for make it output parameter.

Full command will look like this:

ffmpeg -ss 00:00:15 -i song.m4a -t 00:00:30 -acodec copy sample.m4a

And alternatively

ffmpeg -ss 15 -i song.m4a -t 30 -acodec copy sample.m4a

Jet

Posted 2014-05-26T14:49:25.933

Reputation: 2 232

2

Use -to instead of -t: -to specifies the end time, -t specifies the duration...

Say you'd like to grab 30 seconds starting from 00:00:15, you can either specify the start time and the duration...

-ss 00:00:15 -t 00:00:30

... or specify the start time and end time...

-ss 00:00:15 -to 00:00:45

... Both will grab the same 30 seconds of video.

dynamichael

Posted 2014-05-26T14:49:25.933

Reputation: 169

1Please make the relation between -to, -t: and -t more clear. – peterh - Reinstate Monica – 2019-11-30T13:45:00.363