What is the best solution for converting WAV files to WMA (and vice versa) in C#? I have actually implemented this once already using the Windows Media Encoder SDK, but having to distribute Windows Media Encoder with my application is cumbersome to say the least. The Windows Media Format SDK has large sections of the API marked as deprecated. It looks like there might be some DirectX Media Objects (DMOs) I could use from the Windows SDK, but there would be an awful lot of interop to write.
I am wondering if there perhaps is a good managed wrapper for an unmanaged library that can perform the conversions. It would need a license that allows it to be distributed as part of a closed source commercial application.
I haven't tried it personally (so not sure if it's the 'best' solution), but http://www.codeproject.com/KB/audio-video/WmaCompressor.aspx looks like it should meet your requirements...
You can take a look at the BASS library. It has add-ons, such as BASSWMA and BASSEnc for doing encoding/decoding. All its API's are accessible from .NET using the BASS.Net wrapper.
Both BASS and BASS.Net could be licensed for commercial use, with a reasonable fee (€100 each).
If you're comfortable writing a bit of C++/CLI then you don't need much code to create a wrapper around DirectShow to do this. This can then be called directly from a C# assembly with no need to mess about with interop. Doing it with DirectShow is much easier than using WMF directly because you don't have to do any file parsing or I/O - it's all done for you. For reference, I have code in a commercial app that can encode/decode WMA to/from WAV files in less than 100 lines of C++, all wrapped up in a friendly .Net class. Judicious use of smart pointers helps if you go down this route...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With