Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
Posted
Updated 19-Feb-16 9:48am
Comments
Sergey Alexandrovich Kryukov 19-Feb-16 15:36pm    
First of all, it could be different types, like SGM, GSM-EFR, -HR-08...
Try FFMpeg/Libav, please see Solution 2.
—SA

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[^]
 
Share this answer
 
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
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 )
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
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900