This project has moved and is read-only. For the latest updates, please go here.

Strange mp3 playback issue - Mp3Frame parsing or locating at fault?

Aug 16, 2012 at 5:24 AM


I am having a strange issue with some mp3 files.

The symptom is an AcmNotPossible exception in ActmStreamHeader.Convert:


A first chance exception of type 'NAudio.MmException' occurred in NAudio.dll
exception: NAudio.MmException: AcmNotPossible calling acmStreamConvert
   at NAudio.MmException.Try(MmResult result, String function) in D:\Development\c#\ThirdParty\nAudio\1.5\NAudio\Wave\MmeInterop\MmException.cs:line 41
   at NAudio.Wave.Compression.AcmStreamHeader.Convert(Int32 bytesToConvert, Int32& sourceBytesConverted) in D:\Development\c#\ThirdParty\nAudio\1.5\NAudio\Wave\Compression\AcmStreamHeader.cs:line 65


In experimenting, I simply put a try-catch block around:

MmException.Try(AcmInterop.acmStreamConvert(streamHandle, streamHeader, flags), "acmStreamConvert"); 

The strange thing is that the 'corrupt' blocks get ignored and I get playback.

However; there are two different situations:

  • Normal playback
  • Half-speed playback

Having inspected the suspect files, I can say that it appears the half-speed ones are "technically" corrupt in places; although they play fine in applications like VLC and WMP.

I have a suspect that some frames are being incorrectly located or their headers are being decoded incorrectly (from my debug output)

Do you have any advice on how to proceed to resolve this?  I understand that the files are not perfect but the problem is there are a lot like this in a massive library and I'm not in a position to fix the files.

I can provide the mp3 files and/or logging if that will help at all





Aug 17, 2012 at 9:01 PM

this is probably related to sample rate or number of channels changing midway through an MP3 file, which the MP3 file reader in NAudio cannot cope with. You would need to write your own custom code to detect and handle this