无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 794|回复: 6
打印 上一主题 下一主题

[转贴] 使用 LAME 二进制文件轻松地将 WAV 文件编码为 MP3

[复制链接]
跳转到指定楼层
1#
发表于 2023-11-3 09:59:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
转自:How to convert WAV files to MP3 with the command line using LAME like a boss

注:英、中翻译,翻译自必应翻译网址

Learn how to easily encode WAV files to MP3 using the LAME binary.
了解如何使用 LAME 二进制文件轻松地将 WAV 文件编码为 MP3。

How to convert WAV files to MP3 with the command line using LAME like a boss
如何像老板一样使用 LAME 使用命令行将 WAV 文件转换为 MP3
After researching for the best and most optimal tools to convert files in different formats, for WAV files, the LAME project ended up being my favorite solution to convert WAV files to MP3 easily and without losing so much quality, unlike other tools.
在研究了将 WAV 文件转换为不同格式文件的最佳和最优化工具之后,LAME 项目最终成为我最喜欢的解决方案,可以轻松地将 WAV 文件转换为 MP3,而不会损失太多质量,这与其他工具不同。

What is LAME
什么是 LAME
LAME is a high-quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL. Today, LAME is considered the best MP3 encoder at mid-high bitrates and at VBR, mostly thanks to the dedicated work of its developers and the open-source licensing model that allowed the project to tap into engineering resources from all around the world. Both quality and speed improvements are still happening, probably making LAME the only MP3 encoder still being actively developed.
LAME 是根据 LGPL 许可的高质量 MPEG 音频第 III 层 (MP3) 编码器。今天,LAME 被认为是中高比特率和 VBR 下最好的 MP3 编码器,这主要归功于其开发人员的敬业工作和开源许可模式,使该项目能够利用来自世界各地的工程资源。质量和速度的改进仍在进行中,这可能使 LAME 成为唯一仍在积极开发的 MP3 编码器。

1. Download LAME binary for Windows
1. 下载适用于 Windows 的 LAME 二进制文件
The first thing you gotta do is to obtain the LAME binary so we can start encoding the WAV files. As usual with open source, is normal to compile projects from the source code, however as we are in Windows, someone already did it for us. For the LAME project, you can find the latest versions of the LAME encoder on this website.
你要做的第一件事是获取 LAME 二进制文件,这样我们就可以开始对 WAV 文件进行编码了。像往常一样,从源代码编译项目是正常的,但是当我们在 Windows 中时,有人已经为我们做了。对于 LAME 项目,您可以在此网站上找到最新版本的 LAME 编码器。

The packages that you can find on the mentioned website (Packages of LAME), the highest quality MP3 encoder contain:
您可以在上述网站上找到的软件包(LAME 软件包),最高质量的 MP3 编码器包含:

lame.exe - the command line encoder, the one we will use in the Windows command shell.
lame.exe - 命令行编码器,我们将在 Windows 命令行界面中使用的编码器。
lame_enc.dll - LAME encoding library, generally used with CD rippers, etc.
lame_enc.dll - LAME 编码库,一般与 CD 刻录机等一起使用。

In my case, I downloaded LAME 3.100.1, compiled on 2020-09-08 with an Intel 19 Compiler. win32 compile should work on XP, or later. This a point release with NO changes to the encoding library. The internal mpglib decoding library has been replaced with the libmpg123 decoding library. I will extract the content of LAME on my desktop (C:\Users\sdkca\Desktop\lame).
就我而言,我下载了 LAME 3.100.1,它于 2020-09-08 使用英特尔 19 编译器编译。win32 编译应该在 XP 或更高版本上工作。这是一个单点版本,没有对编码库进行任何更改。内部 mpglib 解码库已替换为 libmpg123 解码库。我将在我的桌面(C:\Users\sdkca\Desktop\lame)上提取LAME的内容。

2. Testing the executable
2. 测试可执行文件
Open a new command prompt and switch to the directory where you placed the content of LAME. In my case, it was the desktop:
打开新的命令提示符,然后切换到放置 LAME 内容的目录。就我而言,是桌面:

cd C:\Users\sdkca\Desktop\lame
In the folder, you will find the executable of lame (lame.exe). You can type the following command to get some help about the commands and the way to use LAME:
在文件夹中,您将找到 lame (lame.exe) 的可执行文件。您可以键入以下命令以获取有关命令和 LAME 使用方法的一些帮助:

lame.exe --help
It will output something like:
它将输出如下内容:

LAME 64bits version 3.100.1 (https://lame.sourceforge.io)

usage: lame.exe [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

RECOMMENDED:
    lame -V2 input.wav output.mp3

OPTIONS:
    -b bitrate      set the bitrate, default 128 kbps
    -h              higher quality, but a little slower.
    -f              fast mode (lower quality)
    -V n            quality setting for VBR.  default n=4
                    0=high quality,bigger files. 9.999=smaller files
    --preset type   type must be "medium", "standard", "extreme", "insane",
                    or a value for an average desired bitrate and depending
                    on the value specified, appropriate quality settings will
                    be used.
                    "--preset help" gives more info on these

    --priority type  sets the process priority
                     0,1 = Low priority
                     2   = normal priority
                     3,4 = High priority

    --help id3      ID3 tagging related options

    --longhelp      full list of options

    --license       print License information
Encoding options
编码选项
The mp3 encoding standard allows you to choose a number of encoding parameters. One obvious choice is between mono and stereo sound, where we can also in many cases gain efficiency by encoding the average and difference of left and right channels separately.
mp3 编码标准允许您选择多个编码参数。一个明显的选择是在单声道和立体声之间,在许多情况下,我们还可以通过分别编码左右声道的平均值和差值来提高效率。
More important is the choice of the bitrate, that is the compression ratio. The higher the compression ratio the larger the role of the psychoacoustic model. Only certain bitrates are allowed according to ISO 11172:
更重要的是比特率的选择,也就是压缩比。压缩比越高,心理声学模型的作用越大。根据 ISO 11172,只允许使用某些比特率:

32 kbit/s single_channel only
40 kbit/s mp3 only
48 kbit/s single_channel only
56 kbit/s single_channel only
64 kbit/s
80 kbit/s single_channel only
96 kbit/s
112 kbit/s
128 kbit/s
160 kbit/s
192 kbit/s
224 kbit/s not single_channel
256 kbit/s not single_channel
288 kbit/s mp1 only
320 kbit/s not single_channel
352 kbit/s mp1 only
384 kbit/s mp2 only, not single_channel
416 kbit/s mp1 only
448 kbit/s mp1 only
LAME supports the stereo mode for low bitrates also.
LAME 也支持低比特率的立体声模式。

3. Converting a WAV to MP3
3. 将 WAV 转换为 MP3
There are multiple ways to convert a WAV to MP3 using this tool, it all depends as well on how many resources you want to assign to the task as well as the output quality of the audio (and size of the mp3). The most simple one is to convert it directly with a custom bitrate that you can specify with the -b flag, you can pick a custom bitrate from the previous list, in our case we will use a rate of 128 kbit/s:
使用此工具有多种方法可以将 WAV 转换为 MP3,这完全取决于您要分配给任务的资源数量以及音频的输出质量(和 mp3 的大小)。最简单的方法是直接使用自定义比特率进行转换,您可以使用 -b 标志指定该比特率,您可以从上一个列表中选择自定义比特率,在我们的示例中,我们将使用 128 kbit/s 的速率:

lame -b 128 "C:\Users\sdkca\Desktop\input-file.wav" "C:\Users\sdkca\Desktop\output-file.mp3"
With a WAV file of 43MB and 3:51 of length, the result MP3 is a 3.7MB audio file. Alternatively, you can use one of the presets of LAME:
WAV 文件为 43MB,长度为 3:51,结果 MP3 是一个 3.7MB 的音频文件。或者,您可以使用 LAME 的预设之一:

To activate these presets:
激活这些预设:

   For VBR modes (generally highest quality):
   对于 VBR 模式(通常为最高质量):

     --preset medium      This preset should provide near transparency to most people on most music.
                          这个预设应该在大多数音乐中为大多数人提供近乎透明的效果。

     --preset standard    This preset should generally be transparent to most people on most music and is already quite high in quality.
                          对于大多数音乐,此预设通常对大多数人来说都是透明的,并且质量已经很高。

     --preset extreme     If you have extremely good hearing and similar equipment, this preset will generally provide slightly higher quality than the "standard" mode.
                          如果您的听力和类似设备非常好,此预设通常会提供比“标准”模式略高的质量。

   For CBR 320kbps (highest quality possible from the --preset switches):
   对于 CBR 320kbps(--preset 开关可能提供的最高质量):

     --preset insane      This preset will usually be overkill for most people and most situations, but if you must have the absolute highest quality with no regard to filesize,this is the way to go.
                          对于大多数人和大多数情况来说,此预设通常是矫枉过正的,但是如果您必须在不考虑文件大小的情况下获得绝对最高的质量,那么这就是要走的路。

   For ABR modes (high quality per given bitrate but not as high as VBR):
   对于 ABR 模式(每个给定比特率的质量很高,但不如 VBR 高):

     --preset <kbps>      Using this preset will usually give you good quality at a specified bitrate. Depending on the bitrate entered, this preset will determine the optimal settings for that particular situation. For example:
                          使用此预设通常会在指定的比特率下为您提供良好的质量。根据输入的比特率,此预设将确定该特定情况的最佳设置。例如:
                          "--preset 185" activates this preset and uses 185 as an average kbps.
                          “--preset 185” 激活此预设并使用 185 作为平均 kbps。

   "cbr"  - If you use the ABR mode (read above) with a significant bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320, you can use the "cbr" option to force CBR mode encoding instead of the standard abr mode. ABR does provide higher quality but CBR may be useful in situations such as when streaming an mp3 over the internet may be important.
            如果您使用具有重要比特率(如 80、96、112、128、160、192、224、256、320)的 ABR 模式(如上文),则可以使用“cbr”选项强制 CBR 模式编码,而不是标准 abr 模式。ABR 确实提供了更高的质量,但 CBR 在诸如通过 Internet 流式传输 mp3 可能很重要的情况下可能很有用。

    For example:
    例如:

    --preset standard <input file> <output file>
or --preset cbr 192 <input file> <output file>
or --preset 172 <input file> <output file>
or --preset extreme <input file> <output file>


A few aliases are also available for ABR mode:
一些别名也可用于 ABR 模式:
phone => 16kbps/mono        phon+/lw/mw-eu/sw => 24kbps/mono
mw-us => 40kbps/mono        voice => 56kbps/mono
fm/radio/tape => 112kbps    hifi => 160kbps
cd => 192kbps               studio => 256kbps
For example, if you want to convert a WAV to a CD-quality MP3, the following command should do the trick:
例如,如果要将 WAV 转换为 CD 质量的 MP3,则以下命令应该可以解决问题:

lame --preset cbr 192 "C:\Users\sdkca\Desktop\input-file.wav" "C:\Users\sdkca\Desktop\output-file.mp3"
Which creates a 5.4MB file for our example WAV file (higher quality).
这将为我们的示例 WAV 文件创建一个 5.4MB 文件(更高质量)。

来自 3#
 楼主| 发表于 2023-11-3 10:33:09 | 只看该作者

LAME 3.100.1
2020-09-08
使用英特尔 19 位编译器编译的捆绑包。win32 编译应该在 XP 或更高版本上工作。这是一个单点版本,没有对编码库进行任何更改。内部 mpglib 解码库已替换为 libmpg123 解码库。

下载 win32 捆绑包(1032kB)
下载 x64 捆绑包(1214kB)
回复

使用道具 举报

2#
发表于 2023-11-3 10:25:10 | 只看该作者
谢谢分享
回复

使用道具 举报

4#
发表于 2023-11-3 11:29:27 | 只看该作者
回复

使用道具 举报

5#
发表于 2023-11-3 12:16:58 | 只看该作者
落后了,lame/flac/mac作为开源音频工具,都已经集成到ffmpeg,一个工具能够处理所有音频视频格式。
https://github.com/BtbN/FFmpeg-B ... atest-win64-gpl.zip
回复

使用道具 举报

6#
发表于 2023-11-3 13:12:59 | 只看该作者
感谢分享好东东
回复

使用道具 举报

7#
发表于 2023-11-3 15:15:28 | 只看该作者
谢谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-4-28 18:35

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表