Question

Does anyone have this working? I believe I have the CodecPrivateData messed up, but I can't find any WAVEFORMTEX FormatTags that seem to work. I tried 0xFF00, 0x1016, and 0x0116. I used the MSDN documentation to complete the rest of the string.

I found this in MMReg.h (WAVE_FORMAT_MPEG_ADTS_AAC 0x1600) which would have a FormatTag(0x0016). You would think this is what I should use, but that does not work either.

When using 0xFF if I avoid the adts headers in the stream GetSampleAsync get called repeatedly but there is no playback. I know the stream is good because I can play it in FooBar, VLC, and Window Media Player. When I stick the raw AAC into an MP4 container it works fine in silverlight so I know that the AAC setting are supported by silverlight.

Can someone supply me with a hex CodecPrivateData string that worked for them?

Edit:

This is an example of PrivateCodecData hex string that I think should work:

0x1016010080BB0000E02E0000010000000E000100FE0000000000000000001190

This string goes straight from OpenMediaAsync() to CloseMedia() without even trying a sample. The MSDN documentation example does the same thing found here. I would expect it to at least try a sample before closing.

Was it helpful?

Solution

Silverlight seems to be not compliant with AAC and ADTS wrapper...

If you analyze your MP4 file (with MediaInfo for example), you will see AAC for audio but without ADTS wrapper. This is why Silverlight can read in this case your AAC audio embedded in a MP4 file.

So you need to remove the ADTS header for each audio sample before calling ReportSampleCompleted() in the MediaStreamSource. The ADTS header consists of 7 or 9 bytes (without or with CRC). For more informations about the ADTS header, see this link.

Obviously, you need to adapt your CodecPrivateData string with the right FormatTag. Here is mine for a AAC LC 48KHz @96Kbps file : FF00020080BB0000E02E0000040010000200

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top