MP3 Encoding feature

Mar 3, 2012 at 2:47 PM

Hi, have you ever thought about implementing encoding algorithm for mp3 in managed code? Maybe you already have it in your backlog?

it can be useful in Silverlight 4/WP7 projects, which cannot use native live (like lame)

Coordinator
Mar 3, 2012 at 2:55 PM

I'd love to do this, but it would be a huge undertaking. Keep hoping someone else will do it one day. If there was even a Java version I could port it. I've done unmanaged decoding, but encoding is a much bigger task

Mar 4, 2012 at 3:54 AM

What's the deal with patents on mp3? I know Fedora linux doesn't include mp3 encoding or even decoding because of patent encumbrances, although Fedora does appear to be extremely strict about what they include as a base package. Did you manage to get a license for the decoder that's already in NAudio, or are you just taking advantage of the fact the patent owners no longer pursue authors of free-beer mp3 decoders? I believe it's still the case that anyone distributing encoders in binary form, even if for free, should probably expect a cease & desist order in their future. There's a reason lame can only be downloaded from sourceforge in source form.

To support Silverlight / WP7, I would think the ability to make use of Microsoft's WMA Encoder would make more sense, since that can be used for free by anyone with a valid Windows license.

Now Ogg support is a different matter...

Coordinator
Mar 4, 2012 at 6:25 AM

NAudio uses the MP3 decoder that comes with Windows, which MS has already paid the license fee for. WMA Encoding is possible (I've done it once for a commercial project), but the API is ridiculously overcoomplicated. Fully managed ogg encoding would be a nice idea.

Mar 7, 2012 at 7:09 PM

If I understand this discussion, Lame library is not free of use?
I thought Lame was free!
Please can somebody explain me clearly the around of Lame license.

Coordinator
Mar 7, 2012 at 7:15 PM

LAME is free, but it is not .NET, so can't be part of NAudio. You can easily call LAME.exe using .NET though to convert a WAV file to MP3.

Mar 7, 2012 at 8:55 PM

LAME is free, but numerous patent holders claim it infringes their intellectual property when compiled. The authors of LAME have claimed that it can be distributed in source form as the source is just an educational description of the technologies. That doesn't seem like a watertight argument to me, but the patent owners obviously aren't willing to risk that a court might be convinced by it as they have not initiated legal proceedings.

The LAME team recommends that anyone compiling their software and distributing it in binary form as a part of another product first obtain licenses for the patents. The asking price for those licenses appear to be $2.50/unit, which is obviously a big problem for free software.

And, since it's not .NET, including it in a .NET project would require distributing it in binary form.

Coordinator
Mar 7, 2012 at 8:56 PM

yes, LAME.exe will never be included with NAudio.

Mar 7, 2012 at 10:03 PM
markheath wrote:

NAudio uses the MP3 decoder that comes with Windows, which MS has already paid the license fee for. WMA Encoding is possible (I've done it once for a commercial project), but the API is ridiculously overcoomplicated. Fully managed ogg encoding would be a nice idea.

Yeah, not just overcomplicated, but the programmer's guide seems deficient in the amount of useful guidance.

Xiph's reference implementation of a Vorbis encoder is a little intimidating, but it's only a few thousand lines of C :P

Mar 8, 2012 at 7:31 PM

Thank you for your answers.
As proposed by Coordinator,  If I call Lame.exe in my .Net application (to convert wav to mp3), am I exposed to license penalties?

Mar 9, 2012 at 7:04 PM

In Naudio solution, there is a folder called "Compression''.
Could you tell me if it's possible to compress and decompress audio file with Naudio (without Lame or other additionnal software)?

Coordinator
Mar 10, 2012 at 8:36 AM

NAudio has the WaveFormatConversionStream which uses whatever ACM codecs are on your computer. Windows ships with an MP3 decoder that NAudio uses, but no MP3 encoder. You can however encode to GSM, mu-law, a-law or ADPCM.

Mar 10, 2012 at 1:41 PM
markheath wrote:

NAudio has the WaveFormatConversionStream which uses whatever ACM codecs are on your computer. Windows ships with an MP3 decoder that NAudio uses, but no MP3 encoder. You can however encode to GSM, mu-law, a-law or ADPCM.

Thank you for the answer.
I'm sorry, their compression ratios are not appropriate to my project.

Mar 22, 2012 at 5:04 PM
Edited Mar 22, 2012 at 5:47 PM
loheslath wrote:

If I call Lame.exe in my .Net application (to convert wav to mp3), am I exposed to license penalties?

Depends on your purpose. For personal use, this is not a problem (and even if it was, how would anyone know?) For commercial use of the output, probably technically a violation, but again, how would anyone know? For distributing a software package that includes lame.exe, you're in trouble though, as it's both a violation and discoverable.

On the LAME theme, apparently it's possible to compile an ACM codec from the LAME sources which would be cleaner than calling out to a standalone .exe

loheslath wrote:

I'm sorry, their compression ratios are not appropriate to my project.

There's a Vorbis ACM codec on free-codecs.com although it is ancient and has a 0.0.x version number which doesn't inspire a great deal of confidence.

I am working on a pure-managed implementation of Vorbis based on Xiph's reference implementation, but it's slow going so far.

Jul 22, 2013 at 5:15 AM
Old conversation, but haven't Alvas.Audio already done that? (Pure, managed MP3 encoding/decoding.) That's what I've understood from the reversed DLL.
Coordinator
Jul 22, 2013 at 10:34 AM
There are plenty of MP3 managed decoders (e.g. see NLayer) but I don't know of any encoders. I haven't used Alvas.Audio myself though, so I can't say/
Aug 9, 2013 at 10:22 PM
I noticed that you have since added an encoding option using MediaFoundationEncoder (in the latest beta).
From what I see on MSDN, Windows 7 does seem to support this option, however, I get a null reference exception when I try to use it.
Is this only supported on Windows 8 for some reason?
Aug 10, 2013 at 3:34 AM
Just to add to the conversion: I quickly checked the code, but I think speex port from java to C# has Ogg encoding functionality:
http://cspeex.codeplex.com/.