首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LameMP3FileWriter:不支持的编码格式MuLaw参数名称:格式

LameMP3FileWriter:不支持的编码格式MuLaw参数名称:格式
EN

Stack Overflow用户
提问于 2015-03-05 22:06:18
回答 2查看 2.5K关注 0票数 0

试图将有12年历史的wav文件转换为mp3,

8K,8位,单通道,Mu-Law格式,WAV

我在LameMP3FileWriter行中得到了这个错误:

LameMP3FileWriter:不支持的编码格式MuLaw参数名称:格式

代码语言:javascript
复制
static void Main(string[] args)
{
    string wavFilePath = @"C:\temp\Message.wav";
    string mp3FilePath = @"C:\temp\Message.mp3";
    if (!File.Exists(mp3FilePath))
    {
        byte[] bytearrwav = File.ReadAllBytes(wavFilePath);
        byte[] bytearrmp3 = ConvertWavToMp3(bytearrwav);
        File.WriteAllBytes(mp3FilePath, bytearrmp3);
    }
}

public static byte[] ConvertWavToMp3(byte[] wavFile)
{
    try
    {
        using (var retMs = new MemoryStream())
        using (var ms = new MemoryStream(wavFile))
        using (var rdr = new WaveFileReader(ms))
        using (var wtr = new LameMP3FileWriter(retMs, rdr.WaveFormat, 128))
        {
            rdr.CopyTo(wtr);
            return retMs.ToArray();
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        return null;
    }
}

有人能告诉我如何将这种类型的广域网转换成mp3吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-04-15 16:53:52

最后,我使用SOX和LAME的前男友来转换为可用的wav文件,然后转换为mp3。事实证明,这是一个简单而有效的解决办法。下面是代码的主要部分:

代码语言:javascript
复制
            // create temp file
            tempFile = this.FolderFromFile(inputFileAndPath) + "tempFile.wav";

            // Part 1:  Convert mu-Law WAV to floating point WAV
            // perform work with no display of console window
            // Example:  SOX.EXE  MachMsg1.wav  -e floating-point  MsgFloatingPoint.wav
            using (this)
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process
                {
                    StartInfo = new System.Diagnostics.ProcessStartInfo
                    {
                        FileName = soxFileAndPath,
                        Arguments = inputFileAndPath + "  " + "-e floating-point" + "  " + tempFile,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                };
                proc.Start();
            }


            // Part 2:  Convert floating point WAV to MP3 using highest quality possible
            // perform work with no display of console window
            // Example:  LAME.EXE  -V4  MsgFloatingPoint.wav  MsgFloatingPoint.mp3
            using (this)
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process
                {
                    StartInfo = new System.Diagnostics.ProcessStartInfo
                    {
                        FileName = lameFileAndPath,
                        Arguments = "-V4" + "  " + tempFile + "  " + outputFileAndPath,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                };
                proc.Start();
            }

SOX命令行实用程序: URL:http://sox.sourceforge.net/

版本: SoX 14.4.2于2015年2月22日发布

LAME编译的命令行实用程序: URL:http://www.rarewares.org/mp3-lame-bundle.php

版本: LAME 3.99.5发布于2014年5月22日,Bundle与IntelCompiler14.0.3编译。

代码语言:javascript
复制
  Hydrogenaudio recommended settings
      -- Best quality, "archiving"2 : -b 320 
           CBR 320 is the strongest setting for MP3, with the lowest risk of artifacts. With the exception of a few situations,
           quality is rarely better than the highest VBR profiles described below. 
      -- High quality, HiFi, home or quiet listening : -V0 (avg. 245 kbps) or -V1 (avg. 225 kbps) or -V2 (avg. 190 kbps) or  -V3 (avg. 175 kbps). 
           These settings are considered to produce transparent encoding (transparent = most people can't distinguish the MP3
           from the original in an ABX blind test). Audible differences between these presets exist, but are rare. 
      -- Portable, background noise and low bitrate requirement, small sizes : -V4 (avg. 160 kbps) or -V5 (avg. 130 kbps)
           or -V6 (avg. 115 kbps) -V6 produces an "acceptable" quality, while -V4 should be close to perceptual transparency. 
      -- Very low bitrate, small sizes, eg. for voice, radio, mono encoding : --abr 80 (stereo) or --abr 56 -m m (mono) 
           For very low bitrates, up to 100kbps, ABR is most often the best solution. 
票数 1
EN

Stack Overflow用户

发布于 2015-03-07 11:10:44

在将文件转换为MP3之前,需要将其转换为更标准的格式。用WaveFormatConversionStream.CreatePcmStream实现了从μ定律到线性PCM 16位的转换。接下来的挑战将是,LAME可能不喜欢8 8kHz的音频,所以至少要升级到16 8kHz,可能与另一个WaveFormatConversionStreamMediaFoundationResampler相比更高。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28888685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档