question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NAudio does not support VBR(Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3FileReader does not support sample rate changes)

See original GitHub issue

My requirement is “change the channel as 1, bitrate as 32kbps and splite the time span the mp3 file as 2 minuts”.

 public static Stream ProcessAudioStream(Stream inputStream)
        {
            Stream fs = new MemoryStream();
            Stream outputStream = new MemoryStream();           
            try
            {                

                Stream tempStream = new MemoryStream(); 

                using (var waveStream = new Mp3FileReader(inputStream))
                using (WaveFileWriter waveFileWriter = new WaveFileWriter(tempStream, new Mp3WaveFormat(44100,1,8,32000)))
                {
                    byte[] bytes = new byte[waveStream.Length];
                    waveStream.Read(bytes, 0, (int)waveStream.Length);
                    waveFileWriter.Write(bytes, 0, bytes.Length);
                    waveFileWriter.Flush();
                    fs = BytesToStream(bytes);
                }
                fs.Position = 0;

                using (var mp3 = new Mp3FileReader(fs))
                //Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3FileReader does not support sample rate changes
                {
                    Mp3Frame frame;
                    while ((frame = mp3.ReadNextFrame()) != null)
                    {
                        if ((int)mp3.CurrentTime.TotalSeconds <= 120)//2 mintues
                        {
                            `outputStream.Write(frame.RawData,` 0, frame.RawData.Length);
                        }
                    }
                }
           }
            catch (Exception e)
            {
                string msg = e.Message;

            }
            return outputStream;
        }

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.

Would someone give me some suggestions for this error? thanks In additions, you can click below url to download my source code. Use VS2015 to open the project, thanks. https://pan.baidu.com/s/1qYiEqle

My email is 54373175@qq.com Let me know if you have any comments for this error.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
markheathcommented, Mar 7, 2019

You don’t need the WaveFormatConversionStream - the StreamMediaFoundationReader will already emit PCM

1reaction
RSDNTWKcommented, Apr 7, 2021

Bug is caused by artwork being present in the ID3 Tags. We will open a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Got a frame at sample rate 44100, in an MP3 with ...
Mp3FileReader is throwing an exception: Got a frame at sample rate 44100, in an MP3 with sample rate 48000. Mp3FileReader does not support...
Read more >
Got a frame at sample rate 16000, in an MP3 with ...
Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3filereader does not support sample rate changes.
Read more >
NAudio does not support VBR(Got a frame at sample rate ...
Mp3FileReader is throwing an exception: Got a frame at sample rate 16000, in an MP3 with sample rate 44100. Mp3FileReader does not support...
Read more >
State of MP3 Playback Support in NAudio
It is theoretically possible within an MP3 file for the sample rate and number of channels to change from frame to frame. However,...
Read more >
How to Resample Audio with NAudio
The main takeaway is that if you lower the sample rate, you really ought to use a low pass filter first, to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found