abema / go-mp4

Go library for reading and writing MP4 file
https://dev.to/sunfishshogi/go-mp4-golang-library-and-cli-tool-for-mp4-52o1
MIT License
466 stars 30 forks source link

ReadBoxStructure returns "too large box size" #132

Closed mholt closed 1 year ago

mholt commented 1 year ago

Hi, thanks for this great package! I'm using it with pretty good success so far on a side project of mine.

I am starting to test it with .MOV files from an iPhone; I admit I don't know much about video formats, but I suspect these are H.265 encoded.

I encounter this error frequently (with different size= values, of course, ranging around various kilobytes):

too large box size: type=0x0000002c, size=12399, actualBufSize=4

I believe .MOV files are .MP4 files "under the hood" (I think?) -- so I'm just wondering if this is something that this package supports. If so, what can I do to help with a fix?

sunfish-shogi commented 1 year ago

@mholt Thank you for interest in this library and creating this GH issue.

I created MOV file by Apple QuickTime and tried to input the file into mp4tool. And I found same error.

Screen Shot 2023-02-28 at 15 13 21

I have investigated the MOV file by hexdump.

Screen Shot 2023-02-28 at 15 09 51

In my MOV file, pasp-box is starting at 0xD9D2B and has 0x10 (=16) bytes data. And 4 bytes block following pasp-box is 0x00000000.

ISO/IEC 14496-12 says 0x00000000 of first 4 bytes means "box extends to end of file". However, following 4 bytes 0x00000028 is not box type name, and probably size of stts-box.

So, I think 0x00000000 is padding between boxes.

Sorry, I'm not very familiar with MOV file yet. Please wait for more investigation.

mholt commented 1 year ago

Oh awesome! Thank you for working on this. You know a lot more than me about this :sweat_smile: Let me know if there is any way I can help.

sunfish-shogi commented 1 year ago

references: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap1/qtff1.html https://developer.apple.com/standards/qtff-2001.pdf

sunfish-shogi commented 1 year ago

@mholt Could you try to use fix-qt branch and confirm its ReadBoxStructure returns no error? https://github.com/abema/go-mp4/pull/133

mholt commented 1 year ago

Works for me :) Thank you!