How to play non-PCM file or convert it to PCM on the fly ?

前端 未结 3 1182
悲哀的现实
悲哀的现实 2021-01-20 01:44

The following code works with some wav files, but with others I get, \"InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files.\"

3条回答
  •  春和景丽
    2021-01-20 02:01

    So, do you want to PLAY the file or CONVERT it ? What is the primary goal ? Do you play it as a prove you can convert it, or do you convert it because you don't know how to play not-converted file ? http://www.catb.org/esr/faqs/smart-questions.html#goal

    Your question's title claims "convert" but the body claims "Play"

    This answer is about playing files.


    You also may try to use FFDShow codecs directly without DirectX intermediate. http://en.wikipedia.org/wiki/Libavcodec and http://libav.org/ and http://ffmpeg.org/ (they recently had a schism)

    Googling for "FFDShow dotnet", "libav dotnet", "ffmpeg dotnet" shows a bunch of libraries to use it, such as

    • https://github.com/ermau/libav.net
    • Controlling ffdshow from .Net
    • Solid FFmpeg wrapper for C#/.NET

    There is also BASS library. It is targeted as sound playback during gaming, so it probably has less range of formats and not much for re-coding. Still many music players are built on top of it. Some says it is the most simple API to use. So it worth considering. http://www.un4seen.com/


    http://MediaInfo.sf.net is a library (native win32/win64 DLL) allowing to check most multimedia formats content. I don't know if using tis C or C++ APis is easy from C# side.

提交回复
热议问题