What is the easiest way to programatically convert a compressed wav file (MPEG codec for example, but could be any installed codec) to an uncompressed wav file (16 bit PCM)?
将压缩的wav文件(例如MPEG编解码器,但可以是任何已安装的编解码器)以编程方式转换为未压缩的wav文件(16位PCM)的最简单方法是什么?
I've heard that using direct show and writing the code in native C++ would do it, but I've not had much experience with direct show.
我听说使用直接显示和用原生C ++编写代码就可以了,但是我没有太多直接演示的经验。
Is there an easier way to do this? C# that would be ideal, but C++ would also be fine too.
有更简单的方法吗? C#是理想的,但C ++也会很好。
2 个解决方案
#1
You can decompress WAV files in C# using any ACM codec installed on your PC using NAudio. Here's some sample code:
您可以使用NAudio在PC上安装任何ACM编解码器,在C#中解压缩WAV文件。这是一些示例代码:
using (WaveFileReader reader = new WaveFileReader(inputFileName))
{
using (WaveStream convertedStream =
WaveFormatConversionStream.CreatePcmStream(reader))
{
WaveFileWriter.CreateWaveFile(outputFileName, convertedStream);
}
}
#2
DirectShow is probably the best way to do the decoding, assuming we're talking about Windows. DirectShow is a COM API, so you could write native C++ COM code, you could use one of the available DirectShow .Net wrappers or you could use C++/CLI. Which one you choose depends on the rest of your application architecture - if you need to use .Net then C++/CLI is definitely the easiest route. You really need to be a bit more specific about what you're trying to achieve - for example, MPEG itself is not a codec - they just define standards.
假设我们在谈论Windows,DirectShow可能是解码的最佳方式。 DirectShow是一个COM API,所以你可以编写本机C ++ COM代码,你可以使用一个可用的DirectShow .Net包装器,或者你可以使用C ++ / CLI。您选择哪一个取决于您的应用程序架构的其余部分 - 如果您需要使用.Net,那么C ++ / CLI绝对是最简单的途径。你真的需要更具体地了解你想要实现的目标 - 例如,MPEG本身不是编解码器 - 它们只是定义标准。
#1
You can decompress WAV files in C# using any ACM codec installed on your PC using NAudio. Here's some sample code:
您可以使用NAudio在PC上安装任何ACM编解码器,在C#中解压缩WAV文件。这是一些示例代码:
using (WaveFileReader reader = new WaveFileReader(inputFileName))
{
using (WaveStream convertedStream =
WaveFormatConversionStream.CreatePcmStream(reader))
{
WaveFileWriter.CreateWaveFile(outputFileName, convertedStream);
}
}
#2
DirectShow is probably the best way to do the decoding, assuming we're talking about Windows. DirectShow is a COM API, so you could write native C++ COM code, you could use one of the available DirectShow .Net wrappers or you could use C++/CLI. Which one you choose depends on the rest of your application architecture - if you need to use .Net then C++/CLI is definitely the easiest route. You really need to be a bit more specific about what you're trying to achieve - for example, MPEG itself is not a codec - they just define standards.
假设我们在谈论Windows,DirectShow可能是解码的最佳方式。 DirectShow是一个COM API,所以你可以编写本机C ++ COM代码,你可以使用一个可用的DirectShow .Net包装器,或者你可以使用C ++ / CLI。您选择哪一个取决于您的应用程序架构的其余部分 - 如果您需要使用.Net,那么C ++ / CLI绝对是最简单的途径。你真的需要更具体地了解你想要实现的目标 - 例如,MPEG本身不是编解码器 - 它们只是定义标准。