Closed abadyl closed 6 years ago
probably some kind of corruption in the file, or maybe album art that looks like an MP3 frame. Ideally Mp3FileReader
should cope with this better. Probably we should have had a TryDecompressFrame
method instead.
@abadyl Did you ever find a solution to this? I am facing the same error. Same code... The mp3 plays fine and was created by AWS Polly text to speech service. I don't know how to detect any corruption.
var fileName = syspath + "aud.mpg";
var builder = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
using (var reader = new Mp3FileReader(fileName, builder))
{
WaveFileWriter.CreateWaveFile(syspath+"pcm.wav", reader);
}
Having the same issue here with an MP3 that plays fine on all systems when not using NLayer.NAudioSupport
Here is a sample MP3 that has the error. This same MP3 plays on other boxes using the raw NAudio player. When trying to play the file on a box that has no codecs and using NLayer, I get the error.
I had the same issue and I found the root cause and solution. When the side information is read, in cases where the MPEG version is 2 or higher, only 1 granule should be considered, and the method is reading 2 granules, so it ignores 8 bytes of frame information, causing a reading error. I will submit a pull request solving this.
Hello,
I am trying to decode mp3 file. See simple console app.
var builder = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf)); using (var reader = new Mp3FileReader(@"D:\tEST\3.mp3", builder)) { WaveFileWriter.CreateWaveFile(@"D://tEST/output.wav", reader); }
As result the following exception was thrown.
at NLayer.NAudioSupport.Mp3FrameWrapper.ReadBits(Int32 bitCount) at NLayer.Decoder.BitReservoir.AddBits(IMpegFrame frame, Int32 overlap) at NLayer.Decoder.LayerIIIDecoder.DecodeFrame(IMpegFrame frame, Single[] ch0, Single[] ch1) at NLayer.MpegFrameDecoder.DecodeFrameImpl(IMpegFrame frame, Array dest, Int32 destOffset) at NLayer.MpegFrameDecoder.DecodeFrame(IMpegFrame frame, Byte[] dest, Int32 destOffset) at NLayer.NAudioSupport.Mp3FrameDecompressor.DecompressFrame(Mp3Frame frame, Byte[] dest, Int32 destOffset) at NAudio.Wave.Mp3FileReader.Read(Byte[] sampleBuffer, Int32 offset, Int32 numBytes) at NAudio.Wave.WaveFileWriter.CreateWaveFile(String filename, IWaveProvider sourceProvider) at NAaudioTest.Program.Main(String[] args) in D:\Data\startup\NAaudioTest\NAaudioTest\Program.cs:line 35 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
/Best regards, /Alexey Badyl