21

I am using the 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 the wrong syntax or why it is so?

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

2 Answers 2

30

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
12

Use -to instead of -t.

  1. -t specifies the duration
  2. -to specifies the end time

If you'd like to grab 30 seconds starting from 00:00:15, you can either:

1) Specify the start time and duration.

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

2) Alternatively, specify the start time and end time.

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

Both will grab the same 30 seconds of video.

2
  • 3
    Please make the relation between -to, -t: and -t more clear.
    – peterh
    Commented Nov 30, 2019 at 13:45
  • @peterh I was confused by the -t: momentarily, but I think the colon in the original answer was just punctuation, so it's just -to and -t.
    – mwfearnley
    Commented Feb 20 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .