Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: unable to open m4a file with mp4v2/faad2 but iTunes can read it (Read 6844 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

unable to open m4a file with mp4v2/faad2 but iTunes can read it

I am the author of AACGain. One of my users gave me a file which AACGain is unable to open, but works fine with iTunes and other apps.

I know very little about mp4 container and aac formats, just barely enough to glue mpeg4ip's mp4v2 and faad2 together so they work (but not it this case). So if after reading this post you think I am an idiot, you are probably correct :-)

Here what I do:

In mpeg4ip/mp4v2 I call GetTrackESConfiguration. This looks for property
"mdia.minf.stbl.stsd.*[0].*.esds.decConfigDescr.decSpecificInfo[0].info" in the selected track. It appears to contain a number of properties such as number of channels, sampling rate, etc.

GetTrackESConfiguration returns a buffer which I pass to faad2 method NeAACDecInit2. faad2 calls this the "audio-specific configuration". I am able to use this data to decode the file. This seems to work 99.99% of the time.

In the file that fails, GetTrackESConfiguration returns an error. It is able to find the nested properties up until esds, but fails to find decConfigDescr. But iTunes can open this file with no problems.

Does this mean anything to anyone here? If so, is there an alternate method to find these properties.
Thanks for the help!

Dave

unable to open m4a file with mp4v2/faad2 but iTunes can read it

Reply #1
I have no idea why the mp4 library does not return the right data, probably the mp4 file is "corrupt" or there is some bug in the library.

What you can do when you cannot get this data is try to use NeAACDecInit() instead of NeAACDecInit2(). You don't have to pass any buffer to that, NULL will work. But you have to be a bit careful, you will need to set the right samplerate using the set config function. Otherwise decoding will still fail.

unable to open m4a file with mp4v2/faad2 but iTunes can read it

Reply #2
I have no idea why the mp4 library does not return the right data, probably the mp4 file is "corrupt" or there is some bug in the library.

What you can do when you cannot get this data is try to use NeAACDecInit() instead of NeAACDecInit2(). You don't have to pass any buffer to that, NULL will work. But you have to be a bit careful, you will need to set the right samplerate using the set config function. Otherwise decoding will still fail.


Well I still need to figure out how to find the samplerate then.

I found that faad2/frontend opens the file just fine. I need to compare mp4ff_read_esds with the mp4v2 code to figure out what the difference is.

Thanks!

Dave

unable to open m4a file with mp4v2/faad2 but iTunes can read it

Reply #3
I had someone complain to me that foobar2000 wouldn't open some MP4 file. Turns out it contained ALAC.

unable to open m4a file with mp4v2/faad2 but iTunes can read it

Reply #4
Bill May from the MPEG4IP team took a look at my problem file. He told me it is in Quicktime/mov format instead of mp4 format, and mp4v2 won't read it.

This seems weird to me since many folks have been using aacgain for years, and this is the first time this issue has come up.

In any case, Menno's mp4ff library reads the file's ES config with no problems. So I think I am going to switch over to Menno's code for getting the ES config.

 

unable to open m4a file with mp4v2/faad2 but iTunes can read it

Reply #5
I have some more data on this issue that I wanted to share in case anyone else runs into it.

I need to say that the problem file was created by QTFairUse. At this point I think there is a bug in QTFairUse, even though other players can play the file. If any QTFairUse developers see this, please feel free to comment.

I used the mp4dump utility included with mpeg4ip to examine the file. Here are the 1st 3 bytes of data at the start of the file’s ES Descriptor (in the esds atom):

ReadDescriptor: pos = 0x202
ReadDescriptor: tag 0x03 data size 28 (0x1c)
Read:  ESID = 0 (0x0000)
Read:  streamDependenceFlag = 0 (0x0) <1 bits>
Read:  URLFlag = 0 (0x0) <1 bits>
Read:  OCRstreamFlag = 1 (0x1) <1 bits>
Read:  streamPriority = 0 (0x00) <5 bits>

Note that the OCRstreamFlag is set to 1. This means that the file should contain an OCR_ES_ID field. But it doesn’t seem have one.

mp4v2 tries to read the OCR_ES_ID, which is a 2-byte binary field. Because there isn’t one present, it actually reads the first 2 bytes of the decConfigDescr. Then, when it tries to read the real decConfigDescr, it can’t parse it, because it has already skipped over its 1st 2 bytes.

The corresponding code in Menno's mp4ff doesn't even bother looking at these 3 bytes, it just skips over them and goes straight to the decConfigDescr.

I used a hex text editor to set the OCRstreamFlag bit to zero, and AACGain is able to process that file with no problems.

So I am convinced there is a bug in QTFairUse, which results in OCRstreamFlag being incorrectly set.

If anyone has any more insight into this problem, please let me know.

Thanks!

Dave