问题描述
Mark
我遇到了NAudio的问题,当我使用下面的代码获取MP3文件时,
流stream = new MemoryStream(bytes);
var mp3Reader = new Mp3FileReader(stream);
Mp3FileReader抛出异常:
Hi,Mark
I meet with an issue for NAudio, when I used below codes for MP3file,
Stream stream = new MemoryStream(bytes);
var mp3Reader = new Mp3FileReader(stream);
Mp3FileReader is throwing an exception:
Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3FileReader does not support sample rate changes
你能告诉我我做错了吗?谢谢。
祝你好运!
Jeff Jiang
我尝试过:
使用(WaveStream reader = new Mp3FileReader(inputStream))
using(var temp = new LameMP3FileWriter(tempStream,reader.WaveFormat,LAMEPreset.STANDARD))
{
reader.CopyTo(tempStream);
}
var mp3Reader = new Mp3FileReader(tempStream);
最后一段代码显示此错误消息:
Could you tell me where I am doing wrong? thanks.
Best regards!
Jeff Jiang
What I have tried:
using (WaveStream reader = new Mp3FileReader(inputStream))
using (var temp = new LameMP3FileWriter(tempStream, reader.WaveFormat, LAMEPreset.STANDARD))
{
reader.CopyTo(tempStream);
}
var mp3Reader = new Mp3FileReader(tempStream);
The last code show this error message:
Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3FileReader does not support sample rate changes
我看到这篇文章如何转换(大多数) .NET中的音频格式,但我没有找到问题的解决方案。
我发现一个奇怪的问题:
var testStream = new Mp3FileReader(inputStream);
var outStream = new Mp3FileReader( testStream);
最后一个代码会显示此错误。为什么?
I saw this article"How to convert between (most) audio formats in .NET", but I didn't find the solution for the issue.
I find a strange issue:
var testStream = new Mp3FileReader(inputStream);
var outStream = new Mp3FileReader(testStream);
the last code will show this error. why?
推荐答案
public class MyMp3FileReader : WaveStream
这里特别修改
and here modify especally
private void ValidateFrameFormat(Mp3Frame frame)
此外,您最需要可能还要实现自己的 IMp3FrameDecompressor
和 A cmStream
。
无论如何,这一切都意味着你必须深入研究MP3和ACM(音频压缩管理器)。这真的是一个不错的领域,值得。
对不起,没有最终的解决方案。
我希望它有点帮助位,祝你好运
Furthermore you need most probably also to implement your own IMp3FrameDecompressor
and AcmStream
.
Anyway, all this means you have to dive something deep into MP3 and ACM (Audio Compression Manager). It is really a nice field and it is worth it.
Sorry, not to have a final solution.
I hope it helps little bit, good luck
这篇关于采样率为16000,采样率为44100的MP3格式.Mp3filereader不支持采样率变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!