0

我使用此代码重新采样文件并保存它,但文件听起来像快进录音:

using (MediaFoundationReader reader = new MediaFoundationReader(url))
{
    using (ResamplerDmoStream resampledReader = new ResamplerDmoStream(reader, new WaveFormat(16000, 16, 1)))
        {
            using (WaveFileWriter waveWriter = new WaveFileWriter(@"c:\test.wav", resampledReader.WaveFormat))
                {
                    resampledReader.CopyTo(waveWriter);
                }
         }
}
4

2 回答 2

0

WaveFileWriter必须与WaveFormat相同resampledReaderresampledReader.WaveFormat所以传入WaveFileWriter构造函数。

于 2016-08-25T15:32:36.513 回答
0

我不确定重采样是什么意思,但是如果您需要从视频中获取 wav,这可以...

using (var video = new MediaFoundationReader(file))
{
    file = TempWav;
    WaveFileWriter.CreateWaveFile(file, video);
}
于 2017-11-13T19:03:47.557 回答