如何使用 ffmpeg 将 mp3 从 x 裁剪为 x+n?
在这个问题之后我决定使用ffmpeg进行裁剪MP3。在另一个问题上,我发现了这样做的方法:
ffmpeg -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3
问题是我不想裁剪前 30 秒,我想从 x 裁剪到 x+n,比如从 30 秒裁剪到 100 秒。我该怎么做呢?
我正在阅读 man for ffmpeg 但这并不是很简单,特别是因为我只是发现了 ffmpeg 并且我不熟悉音频/视频编辑软件,因此任何指示将不胜感激。
Following this question I decided to use ffmpeg to crop MP3s. On another question I found this way of doing it:
ffmpeg -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3
The problem is that I don't want to crop the first 30 seconds, I want to crop from x to x+n, like from 30s to 100s. How would I go and do this?
I'm reading the man for ffmpeg but this is not really straightforward, especially since I just discovered about ffmpeg and I'm not familiar with audio/video editing softwares, so any pointers would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 -t 和 -ss 参数。他们应该做你想做的事。
例如, ffmpeg -ss 30 -t 70 -i inputfile.mp3 -acodec copy outputfile.mp3 应该可以满足您提到的范围(30s-100s)。
Take a look at the -t and -ss arguments. They should do what you want.
For example,
ffmpeg -ss 30 -t 70 -i inputfile.mp3 -acodec copy outputfile.mp3
should do the trick for the range you mentioned (30s-100s).稍微扩展一下 Michael Madsens 的回答:
我发现以下任一方法都可以满足修剪音频文件的要求:
ffmpeg -ss
<开始位置>-t
< ;duration>-i inputfile -c:复制输出文件
ffmpeg -ss
<开始位置>-i inputfile -t
-c:a copy outputfile
注意:
-acodec
是codec:a
的别名,也可以指定为c:a
如主要选项 FFMPEG 文档中指定
-t 持续时间(输入/输出)
-ss 位置(输入/输出)
duration
和position
遵循 持续时间语法:[-][HH:]MM:SS[.m...]
或[-]S+[.m...][s| ms|us]
旁注:如何使用 FFMPEG 检测静音间隔的答案可能也很有趣。
作为输入或输出的搜索和持续时间之间的差异
我对以下文件做了几次测试:
与原始文件相比,在 Audacity 中对齐输出并得到以下结果:
ffmpeg -ss 3 -t 5 -i test16s.mp3 -c:a copy out.mp3- 开始:3s+00756samples (3.017142857s)
- 结束:8s+02062samples (8.04675737s)
- 持续时间:5 秒+01306 个样本(5.029614512 秒)
ffmpeg -ss 3 -i test16s.mp3 -t 5 -c:a copy out.mp3
ffmpeg -i test16s.mp3 -ss 3 -t 5 -c:a copy out.mp3
ffmpeg -t 5 -i test16s.mp3 -ss 3 -c:a copy out.mp3
在尝试查看搜索跳转时,我发现了有趣的结果
使用:
ffmpeg -ss
<秒>-i test16s.mp3 -t 5 -c:a copy out.mp3
ffmpeg -ss
-t 5 -i test16s.mp3 -c:a copy out.mp3
最后,使用流复制,看起来就像我的特定文件中的最小搜索分辨率一样,(音频:mp3,44100 Hz、立体声、fltp、128 kb/s),为:
To expand a bit on Michael Madsens' Answer:
I've found either of the following satisfactory for trimming my audio files:
ffmpeg -ss
<start position>-t
<duration>-i inputfile -c:a copy outputfile
ffmpeg -ss
<start position>-i inputfile -t
<duration>-c:a copy outputfile
Note:
-acodec
is an alias forcodec:a
which can be specified also asc:a
As specified in the Main Options FFMPEG Documentation
-t duration (input/output)
-ss position (input/output)
duration
andposition
follow the Time Duration Syntax :[-][HH:]MM:SS[.m...]
or[-]S+[.m...][s|ms|us]
Side Note: An answer on How to detect intervals of silence with FFMPEG may also be of interest.
Differences between seeking and duration as input or output
I did a couple Tests on the following file:
Aligned the outputs in Audacity in comparison to the original and got the following:
ffmpeg -ss 3 -t 5 -i test16s.mp3 -c:a copy out.mp3
ffmpeg -ss 3 -i test16s.mp3 -t 5 -c:a copy out.mp3
ffmpeg -i test16s.mp3 -ss 3 -t 5 -c:a copy out.mp3
ffmpeg -t 5 -i test16s.mp3 -ss 3 -c:a copy out.mp3
In an attempt to get to see the seek jump I found interesting results
using :
ffmpeg -ss
<secs>-i test16s.mp3 -t 5 -c:a copy out.mp3
ffmpeg -ss
<secs>-t 5 -i test16s.mp3 -c:a copy out.mp3
Concluding that with a Stream Copy, appears as if the minimal seek resolution in my specific file ,(Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s), was: