采样率为16000,采样率为44100的MP3格式.Mp3filereader不支持采样率变化 [英] Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3filereader does not support sample rate changes

查看:608
本文介绍了采样率为16000,采样率为44100的MP3格式.Mp3filereader不支持采样率变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

推荐答案

我对你的示例项目做了一些简短的测试,事实是, NAudio不支持VBR 。最可能的原因是,VBR通常不容易进行位置处理。



根据您的目标,您可以例如寻找另一个音频库或者如果您想继续使用NAudio并且您只想实现MP3 To WAV转换器,您可以下载NAudio的一些源文件并根据您的需要修改一些类。



这是什么意思:

下载 [ ^ ] https://github.com/naudio/NAudio/blob/master/NAudio/Wave/WaveStreams/Mp3FileReader.cs并将其作为基础,以类<$ c实现您自己的MyMp3FileReader.cs $ c> MyMp3FileReader 。

I made some short tests with your sample project and the thing is, that NAudio does not support VBR. The reason for this most probably is, that VBR usually is not easy for position handling.

Depending on your target you can e.g. looking for another Audio Library or in case you like to proceed with NAudio and you only like to implement a MP3 To WAV converter you can download some of the source files of NAudio and modify some of the classes according to your needs.

What does this about mean:
download [^]https://github.com/naudio/NAudio/blob/master/NAudio/Wave/WaveStreams/Mp3FileReader.cs and take it as base to implement your own MyMp3FileReader.cs with a class MyMp3FileReader.
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


你应该在文章的底部发布你的问题: ^ ]

这就像马克获得通知并且可能会回答。



BTW:你在谈论VBR吗?
You should post your question at the bottom of the article: How to convert between (most) audio formats in .NET[^]
This like Mark get informed and will maybe answer.

BTW: Are you talking about VBR?


这篇关于采样率为16000,采样率为44100的MP3格式.Mp3filereader不支持采样率变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆