Using ffmpeg to cut audio from/to position
This works for me
ffmpeg -ss 60 -i input-audio.aac -t 15 -c copy output.aac
- -ss 60 means, "start from second 60"
- -t 15 audio output length in seconds.. in this case, 15 seconds..
With FFmpeg the ordering of parameters is significant. All of the parameters that come directly before an input will apply to that input. The same is true for an output... the parameters directly before it apply to the output.
Consider this command line:
ffmpeg -ss 132 -i input.mp3 output.mp3
-ss
is the parameter to seek, so FFmpeg will seek the input file to 132 seconds in and treat that effectively at 00:00:00
. The rest of your FFmpeg commands relative to the output don't know or care where that input came from or how it was seeked. Therefore, when you use -to
or -t
, the times or lengths given need to be relative to the input. That is, if you want seconds 132 through 139, you want to seek the input to 132 (-ss 132 -i input.mp3
), and then run the output for 7 seconds (-t 7 output.mp3
or -to 00:00:07 output.mp3
).
You can read more about this, as well as details about frame-accurate or not (for re-encoding or not) on the documentation: https://trac.ffmpeg.org/wiki/Seeking
As for -to
not being there...
As I shown above, I have the latest version of the software.
You absolutely positively do not remotely have the latest version of FFmpeg. You might have the latest build of whatever branch whatever package manager has, and it may have been built this year, but if you check the download page, the latest release as of this writing is 3.3.4. https://www.ffmpeg.org/download.html
You can either deal with your package manager and dependency hell, or depending on your licensing restrictions, snag a recent static build: https://www.johnvansickle.com/ffmpeg/
Finally, consider -acodec copy
to ensure you're not hurting the quality of your audio further by transcoding, since you're keeping the same format.