简体   繁体   English

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

[英]sox - how to create mp3 file with bit rate 16kbps

Currently the command used is 目前使用的命令是

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

But this is creating a file with bit rate 24.0 kbps. 但这是创建一个比特率为24.0 kbps的文件。

How to make the bit rate of the out put file to 16.0 kbps? 如何使输出文件的比特率达到16.0 kbps?

In the sox formats manual you find, that it is the -C option. sox格式手册中,您会发现它是-C选项。 Below I quote the whole section because you may find it interesting. 下面我引用整个部分,因为你可能会发现它很有趣。

However, if I call sox test.wav -C 16.01 test.mp3 my testfile (48kHz/16bit) is converted to 32kbps. 但是,如果我调用sox test.wav -C 16.01 test.mp3我的testfile(48kHz / 16bit)将转换为32kbps。 If I call lame test.wav -b 16 -q 0 test.mp3 I get 16kbps but test.mp3 is converted to a samplerate of 8kHz. 如果我调用lame test.wav -b 16 -q 0 test.mp3我得到16kbps但test.mp3转换为8kHz的采样率。 But if I really want to keep my 48kHz with lame test.wav -b 16 -q 0 --resample 48000 test.mp3 I also get 32kbps. 但是,如果我真的想保持我的48kHz lame test.wav -b 16 -q 0 --resample 48000 test.mp3我也得到32kbps。 So we see, there is a compromise between a high samplerate and a high compression ratio. 我们看到,高采样率和高压缩比之间存在折衷。

MP3 compressed audio; MP3压缩音频; MP3 (MPEG Layer 3) is a part of the patent-encumbered MPEG standards for audio and video compression. MP3(MPEG Layer 3)是用于音频和视频压缩的受专利保护的MPEG标准的一部分。 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. 由于MP3已获得专利,SoX无法在不支付专利持有人费用的情况下支持MP3。 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. 需要具有MP3支持的SoX的用户当前必须使用源代码中的MP3库(LAME和MAD)编译和构建SoX,或者在某些情况下,获取预构建的动态可加载库。

When reading MP3 files, up to 28 bits of precision is stored although only 16 bits is reported to user. 读取MP3文件时,尽管只向用户报告了16位,但仍会存储高达28位的精度。 This is to allow default behavior of writing 16 bit output files. 这是为了允许写入16位输出文件的默认行为。 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输出文件将使用高达24位的精度。

MP3 compression parameters can be selected using SoX's −C option as follows (note that the current syntax is subject to change): 可以使用SoX的-C选项选择MP3压缩参数,如下所示(请注意,当前语法可能会发生变化):

The primary parameter to the LAME encoder is the bit rate. LAME编码器的主要参数是比特率。 If the value of the −C value is a positive integer, it's taken as the bitrate in kbps (eg if you specify 128, it uses 128 kbps). 如果-C值的值为正整数,则将其视为以kbps为单位的比特率(例如,如果指定128,则使用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. 在LAME中,0表示最高质量但速度很慢,而9表示质量差,但速度很快。 (5 is the default and 2 is recommended as a good trade-off for high quality encodes.) (默认值为5,推荐使用2作为高质量编码的良好折衷方案。)

Because the −C value is a float, the fractional part is used to select quality. 因为-C值是浮点数,所以小数部分用于选择质量。 128.2 selects 128 kbps encoding with a quality of 2. There is one problem with this approach. 128.2选择质量为2的128 kbps编码。这种方法存在一个问题。 We need 128 to specify 128 kbps encoding with default quality, so 0 means use default. 我们需要128来指定默认质量的128 kbps编码,因此0表示使用默认值。 Instead of 0 you have to use .01 (or .99) to specify the highest quality (128.01 or 128.99). 而不是0,你必须使用.01(或.99)来指定最高质量(128.01或128.99)。

LAME uses bitrate to specify a constant bitrate, but higher quality can be achieved using Variable Bit Rate (VBR). LAME使用比特率指定恒定比特率,但使用可变比特率(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. 使用0到9之间的数字选择VBR质量(实际大小)。对于高质量,大文件使用值0,对于较低质量的较小文件使用值9。 4 is the default. 4是默认值。

In order to squeeze the selection of VBR into the the −C value float we use negative numbers to select VRR. 为了将VBR的选择压缩到-C值浮点数,我们使用负数来选择VRR。 -4.2 would select default VBR encoding (size) with high quality (speed). -4.2将选择具有高质量(速度)的默认VBR编码(大小)。 One special case is 0, which is a valid VBR encoding parameter but not a valid bitrate. 一种特殊情况是0,它是有效的VBR编码参数,但不是有效的比特率。 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). 压缩值0始终被视为高质量vbr,因此-0.2和0.2都被视为最高质量的VBR(大小)和高质量(速度)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM