gpt4 book ai didi

audio - sox-如何以16kbps的比特率创建mp3文件

转载 作者:行者123 更新时间:2023-12-04 16:52:39 26 4
gpt4 key购买 nike

当前使用的命令是

    `sox input.wav -G -t mp3 -r 16k test.mp3`

但这正在创建一个比特率为24.0 kbps的文件。

如何使输出文件的比特率达到16.0 kbps?

最佳答案

sox formats manual中,您可以找到-C选项。下面我引用了整个部分,因为您可能会发现它很有趣。
但是,如果我调用sox test.wav -C 16.01 test.mp3,我的测试文件(48kHz/16bit)将转换为32kbps。如果我调用lame test.wav -b 16 -q 0 test.mp3,我会得到16kbps的速度,但是test.mp3会转换为8kHz的采样率。但是,如果我真的想用lame test.wav -b 16 -q 0 --resample 48000 test.mp3保持48kHz,我也会得到32kbps。因此我们看到,在高采样率和高压缩比之间存在折衷。

MP3 compressed audio; MP3 (MPEG Layer 3) is a part of the patent-encumbered MPEG standards for audio and video compression. It is a lossy compression format that achieves good compression rates with little quality loss.

Because MP3 is patented, SoX cannot be distributed with MP3 support without incurring the patent holder’s fees. Users who require SoX with MP3 support must currently compile and build SoX with the MP3 libraries (LAME & MAD) from source code, or, in some cases, obtain pre-built dynamically loadable libraries.

When reading MP3 files, up to 28 bits of precision is stored although only 16 bits is reported to user. This is to allow default behavior of writing 16 bit output files. A user can specify a higher precision for the output file to prevent lossing this extra information. MP3 output files will use up to 24 bits of precision while encoding.

MP3 compression parameters can be selected using SoX’s −C option as follows (note that the current syntax is subject to change):

The primary parameter to the LAME encoder is the bit rate. If the value of the −C value is a positive integer, it’s taken as the bitrate in kbps (e.g. if you specify 128, it uses 128 kbps).

The second most important parameter is probably "quality" (really performance), which allows balancing encoding speed vs. quality. In LAME, 0 specifies highest quality but is very slow, while 9 selects poor quality, but is fast. (5 is the default and 2 is recommended as a good trade-off for high quality encodes.)

Because the −C value is a float, the fractional part is used to select quality. 128.2 selects 128 kbps encoding with a quality of 2. There is one problem with this approach. We need 128 to specify 128 kbps encoding with default quality, so 0 means use default. Instead of 0 you have to use .01 (or .99) to specify the highest quality (128.01 or 128.99).

LAME uses bitrate to specify a constant bitrate, but higher quality can be achieved using Variable Bit Rate (VBR). VBR quality (really size) is selected using a number from 0 to 9. Use a value of 0 for high quality, larger files, and 9 for smaller files of lower quality. 4 is the default.

In order to squeeze the selection of VBR into the the −C value float we use negative numbers to select VRR. -4.2 would select default VBR encoding (size) with high quality (speed). One special case is 0, which is a valid VBR encoding parameter but not a valid bitrate. Compression value of 0 is always treated as a high quality vbr, as a result both -0.2 and 0.2 are treated as highest quality VBR (size) and high quality (speed).

关于audio - sox-如何以16kbps的比特率创建mp3文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26715383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com