gavinljj / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 0 forks source link

MP4ReadSample fails on iTunes music video files #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. MP4FileHandle fh = MP4Open(fn); //fn is an iTunes music video file
2. bool rc = MP4ReadSample(fh, 2, 1, &pBytes, &numBytes); //2 is the trackId of 
the audio 'soun' track 

What is the expected output? What do you see instead?

Expected output: rc is true

Observed output: rc is false, and 
"mp4v2 error: MP4Array::[]:index 1 of 1:Result too large"
is printed on console

What version of the product are you using? On what operating system?

mp4v2-trunk-r355 on Windows XP SP3.

Please provide any additional information below.

The problem is caused by function MP4Track::GetSampleFile assuming that 
"trak.mdia.minf.dinf.dref" contains a child atom of type 'url ', and blindly 
goes ahead to retrieve the url's "location" property without checking the child 
atom's type. However, in iTunes music video files, there is no url child atom. 
Instead the dref child atom is of type 'cios'.

The following patch fixes the bug:

--- mp4track.cpp        2009-05-23 06:29:37.000000000 -0700
+++ mp4track.cpp        2010-07-16 15:13:17.578125000 -0700
@@ -898,6 +898,14 @@

     File* file;

+    //start patch
+    //support iTunes videos which contain 'cios'
+    //instead of 'url ' child of dref atom
+    if (strcmp(pUrlAtom->GetType(), "url ")) {
+        file = NULL;
+    }
+    else
+    //end patch
     if( pUrlAtom->GetFlags() & 1 ) {
         file = NULL; // self-contained
     }

A sample file that reproduces the problem can be found here:
http://rapidshare.com/files/402214087/Jeremy.mp4.html

I am the author of aacgain, and this problem has been reported to my by my 
users.

This bug is also in the original code in sourceforge.

Original issue reported on code.google.com by davelas...@gmail.com on 16 Jul 2010 at 11:55

GoogleCodeExporter commented 9 years ago
davelasker,

Thanks for reporting this.  let me review the mp4 specs and I'll see if I can 
get this resolved in trunk today.

Thanks!

Original comment by kid...@gmail.com on 22 Jul 2010 at 6:01

GoogleCodeExporter commented 9 years ago
Okay, this should be resolved in r390.  I reproduced it with the file, and your 
fix does work.

I'm still curious why it doesn't have a "url " atom, and I couldn't find any 
information about this "cios" atom.  Do you have any idea where that's 
documented?

Thanks for the patch!

Original comment by kid...@gmail.com on 22 Jul 2010 at 7:07

GoogleCodeExporter commented 9 years ago
I have no idea what a "cios" atom is. My Googling for it came up pretty much 
empty. I did find a reference to it in the AtomicParsley source code. Maybe 
someone from the AtomicParsley team knows what it is.

Thanks for the fix!

Dave

Original comment by davelas...@gmail.com on 22 Jul 2010 at 8:50