从 wav 和 aiff 文件创建 mp3 预览
我想创建一个程序来制作 aiff 或 wav 文件前 30 秒的 mp3。我还希望能够选择位置和长度,例如 2:12 到 2:42 之间的音频。有没有任何工具可以让我做到这一点?
脱壳就OK了。该应用程序将在 Linux 服务器上运行,因此它必须是一个可以在 Linux 上运行的工具。
我不介意分两步完成——即首先创建 aiff/wav 剪切图的工具,然后将其传递给 mp3 编码器。
I would like to create a program that makes mp3s of the first 30 seconds of an aiff or wav file. I would also like to be able to choose location and length, such as the audio between 2:12 and 2:42. Are there any tools that lets me do this?
Shelling out is OK. The application will run on a linux server, so it would have to be a tool that works on linux.
I don't mind doing it in two steps - i.e. a tool that first creates the cutout of the aiff/wav, then pass it to a mp3 encoder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
SoX
和trim
谓词可以做到这一点。如果您的 sox 没有构建 MP3 支持,那么您必须在之后将输出通过管道传输到 lame,或者找到一个支持 MP3 的。SoX
with thetrim
predicate can do this. If your sox is not built with MP3 support then you'll have to pipe the output tolame
after, or find one that is.我想使用尽可能低级别的东西,所以我最终使用了
RubyAudio
,libsndfile 的包装器。I wanted to use something as low level as possible, so I ended up using
RubyAudio
, a wrapper for libsndfile.使用 LAME 作为 mp3 编码部分。使用 shntplit 分割文件。您需要将分割点放入提示文件中,但这很容易。
Use LAME for the mp3 encoding part. Use shntplit to split the file. You will need to put your split points in a cue file, but that is easy.
在包含 *.wav 文件的目录中运行此 Bash 单行代码。
第一个 60 秒。 3 秒淡入和 3 秒淡出。原始 wav 文件保持不变。预览文件带有“preview-”前缀。您可以通过更改“trim 0 60”来选择位置和长度以满足您的需求。
需要:sox、lame
如果您有一个包含 mp3 文件的目录并且需要创建预览,请运行以下命令:
需要:mpg123、sox、lame
Run this Bash one-liner in a directory with *.wav files.
First 60 seconds. 3 seconds fade-in and 3 seconds fade-out. Original wav files stay untouched. Preview files come with a "preview-" prefix. You'll be able to choose location and length by changing "trim 0 60" to fit Your needs.
Requires: sox, lame
If You have a directory with mp3 files and need to create previews, run this:
Requires: mpg123, sox, lame
我写了一个 python 库 pydub,这使得这变得微不足道,尽管它使用 ffmpeg 来进行转换以支持更多格式...
I wrote a python library, pydub, that makes this trivial, though it uses ffmpeg in to do the conversions in order to support more formats…