使用开始和停止时间修剪音频文件

whi*_*ngs 68 ffmpeg audio trim

我有一个 FFmpeg 命令来修剪音频:

ffmpeg -ss 01:43:46 -t 00:00:44.30 -i input.mp3 output.mp3
Run Code Online (Sandbox Code Playgroud)

我使用此命令的问题是该选项-t需要从01:43:46 开始的持续时间(以秒为单位)。我想使用开始/停止时间修剪音频,例如在01:43:4600:01:45.02 之间

这可能吗?

Mia*_*ati 104

ffmpeg 似乎在文档中有一个新选项-to

-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
Run Code Online (Sandbox Code Playgroud)

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

  • 是否可以有多个间隔并将它们连接在一起?即`ffmpeg -i file.mp3 -ss 10 -to 11 -ss 20 -to 21 -ss 30 -to 31 ....` (4认同)
  • Tx,效果很好。我发现如果我不删除 `copy` 部分音频/视频不同步,所以我删除它并添加 `-async 1`,它就像一个魅力。当然,它需要重新编码,因此改进将是一个允许“复制”但没有同步问题的命令。 (2认同)