C#如何将wav转换为mp3,但格式为gsm610 [英] C# how to convert wav to mp3 but it format is gsm610

查看:163
本文介绍了C#如何将wav转换为mp3,但格式为gsm610的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Wav转换为Mp3,但它使用NAudio.Wave抛出不支持的编码格式Gsm610



;

使用NAudio.Lame;



string wavFile = Server.MapPath(/ File / 825558.wav);

string mp3File = Server.MapPath(/ File / 825558.mp3);

var reader = new WaveFileReader(wavFile);

using(var writer = new LameMP3FileWriter(mp3File) ,reader.WaveFormat,LAMEPreset.VBR_90))

reader.CopyTo(作家);



我的尝试:



使用NAudio.Wave;

使用NAudio.Lame;



string wavFile = Server.MapPath(/ File / 825558.wav);

string mp3File = Server.MapPath(/ File / 825558.mp3);

var reader = new WaveFileReader(wavFile);

using(var writer = new LameMP3FileWriter(mp3File,reader.WaveFormat,LAMEPreset.VBR_90))

reader.CopyTo (作家);

I want to Convert Wav To Mp3 but it throw Unsupported encoding format Gsm610

using NAudio.Wave;
using NAudio.Lame;

string wavFile = Server.MapPath("/File/825558.wav");
string mp3File = Server.MapPath("/File/825558.mp3");
var reader = new WaveFileReader(wavFile);
using (var writer = new LameMP3FileWriter(mp3File, reader.WaveFormat, LAMEPreset.VBR_90))
reader.CopyTo(writer);

What I have tried:

using NAudio.Wave;
using NAudio.Lame;

string wavFile = Server.MapPath("/File/825558.wav");
string mp3File = Server.MapPath("/File/825558.mp3");
var reader = new WaveFileReader(wavFile);
using (var writer = new LameMP3FileWriter(mp3File, reader.WaveFormat, LAMEPreset.VBR_90))
reader.CopyTo(writer);

推荐答案

如果你得到一个您不理解的错误消息,将其传递给Google:您可能不是第一个遇到它的人。如果是这种情况,您会收到很多回复: WaveFileReader不支持的编码格式Gsm610 - Google搜索 [ ^ ]

第一个链接似乎解释了几个解决方案的问题:wav - LameMP3FileWriter:不支持的编码格式MuLaw参数名称:格式 - 堆栈溢出 [ ^ ]
If you get an error message you don't understand, pass it to Google: the chances are you aren't the first to meet it. If this case you get a lot of responses: WaveFileReader Unsupported encoding format Gsm610 - Google Search[^]
The first link appears to explain the problem with a couple of solutions: wav - LameMP3FileWriter: Unsupported encoding format MuLaw Parameter name: format - Stack Overflow[^]


首先,一般来说,你需要更强大的编解码器支持软件源。你想使用相对异国情调的编解码器,LAME是完全不适合它的东西。另请参阅我对该问题的评论。答案可能取决于您尝试使用的确切配置文件( RTP音频视频配置文件 - 维基百科,免费的百科全书 [< a href =https://en.wikipedia.org/wiki/RTP_audio_video_profiletarget =_ blanktitle =New Window> ^ ])。



在最棘手的情况下帮助我的一个软件包是基于它的库libav或FFMpeg,这两个产品还包括几乎相同的即用型实用程序:

http://en.wikipedia.org/wiki/Ffmpeg [ ^ ],

http:// ffmpeg .org / [ ^ ],

< a href =http://en.wikipedia.org/wiki/Libavcodec> http://en.wikipedia.org/wiki/Libavcodec [ ^ ],

http://libav.org/ [ ^ ]。



在这两种情况下,您都可以获得免费的开源实用程序,它几乎可以创建所有内容。



现在,如何在.NET应用程序中以编程方式使用它?首先,您可以使用 System.Diagnostics.Process.Start 运行它来使用可用的实用程序:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx [ ^ ]。



如果这还不够好,你可以自己将库包装在.NET程序集中,或找到合适的包装器。请参阅:

http://www.ffmpeg-csharp.com/ [ ^ ],

http://sourceforge.net/projects/sharpffmpeg/ [ ^ ],

http://vbffmpegwrapper.codeplex.com/ [ ^ ]。



毕竟,尝试找一些: http://bit.ly/VpboUJ [ ^ ]。



如果你想工作在你自己的包装但不知道如何,问一个问题,我会给你基本的想法(使用P / Invoke或C ++ / CLI混合模式项目)。



现在,基于tha t,我使用参数
First of all, generally, you need more powerful source of codec-supporting software. You want to use relatively exotic codec, and LAME is something totally unsuitable to it. See also my comment to the question. The answer may depends on what exactly profile you are trying to use (RTP audio video profile — Wikipedia, the free encyclopedia[^]).

One software package which helped me the most in most tricky situation is the library libav or FFMpeg based on it, both products also include near-identical ready to use utilities:
http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

In both cases, you can get free open-source utilities which can make nearly everything.

Now, how to use it programmatically in a .NET application? First, you can use the available utility by running it using System.Diagnostics.Process.Start:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx[^].

If this is not good enough, you can wrap the library in a .NET assembly by yourself or find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].

After all, try to find some more: http://bit.ly/VpboUJ[^].

If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).

Now, based on that, I ran the FFMpeg utility with the parameter
ffmpeg -codecs

运行FFMpeg实用程序并获得以下行:

and obtained the following lines:

DEA.L. gsm    GSM (decoders: gsm libgsm ) (encoders: libgsm )
DEA.L. gsm_ms GSM Microsoft variant (decoders: gsm_ms libgsm_ms ) (encoders: libgsm_ms )

因此,您可以对某种媒体文件进行解码进行一些更改。适用指标DEA.L.意思是:

Therefore, you have some change that your kind of media file can be decoded. The applicabiliy indicator "DEA.L." means:

D..... = Decoding supported
.E.... = Encoding supported
..V... = Video codec
..A... = Audio codec
..S... = Subtitle codec
...I.. = Intra frame-only codec
....L. = Lossy compression
.....S = Lossless compression

也就是说,你可以解码,编码,支持有损压缩;这是音频编解码器;只有两个项目不受支持/不适用;没有损失压缩。



祝你好运,

-SA

That is, you can decode, encode, the lossy compression is supported; this is audio codec; only two items are unsupported/unapplicable; there is no lossles compression.

Good luck,

—SA


这篇关于C#如何将wav转换为mp3,但格式为gsm610的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆