我使用此代码重新取样文件并保存,但文件听起来像快进录制:
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);
}
}
}
答案 0 :(得分:0)
WaveFileWriter
必须与WaveFormat
具有相同的resampledReader
。因此,将resampledReader.WaveFormat
传递给WaveFileWriter
构造函数。
答案 1 :(得分:0)
我不确定重采样是什么意思,但是如果您需要从视频中获取wav,这可行...
using (var video = new MediaFoundationReader(file))
{
file = TempWav;
WaveFileWriter.CreateWaveFile(file, video);
}