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
458 stars 31 forks source link

Support old QuickTime atoms #7

Open sunfish-shogi opened 4 years ago

sunfish-shogi commented 4 years ago

hdlr atom

Bento4 detects pstring by length. https://github.com/axiomatic-systems/Bento4/blob/v1.6.0-637/Source/C++/Core/Ap4HdlrAtom.cpp#L95

Libquicktime detects by component_type field. https://sourceforge.net/p/libquicktime/git/ci/master/tree/src/hdlr.c#l208

Android detects by path. https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#2570

meta atom

Android detects by path. https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#2382

udta atom

Android: https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#989

alac sample entry

Android: https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#1650, https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#1204

keys atom

https://developer.apple.com/documentation/quicktime-file-format/metadata_item_keys_atom

Android: https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#2598

ilst atom

Android: https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#2879

AudioSampleEntry

wave atom

Bento4: https://github.com/axiomatic-systems/Bento4/blob/v1.6.0-637/Source/C%2B%2B/Core/Ap4AtomFactory.cpp#L794 Android: https://android.googlesource.com/platform/frameworks/av/+/master/media/extractors/mp4/MPEG4Extractor.cpp#919

ctts atom

(investigation required)

Bento4: https://github.com/axiomatic-systems/Bento4/blob/v1.6.0-637/Source/C%2B%2B/Core/Ap4CttsAtom.cpp#L98

wide atom

http://xhelmboyx.tripod.com/formats/mp4-layout.txt

fiel atom

http://xhelmboyx.tripod.com/formats/mp4-layout.txt https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html

sunfish-shogi commented 4 years ago

Sometimes, name field of hdlr box has 0x00 twice.

Following images are mp4tool-dump and hexdump of the music mp4 file written by Sony's product.

Screen Shot 2020-07-25 at 2 57 02 Screen Shot 2020-07-25 at 3 06 09 Screen Shot 2020-07-25 at 3 01 01 Screen Shot 2020-07-25 at 3 08 13

In this file, only hdlr box which is under moov->udta->meta has 34 bytes. And this box has handler type mdir and has appl at next 4 bytes.

https://github.com/abema/go-mp4/pull/4/files#diff-e6c932c76afb2ffea73af8d48df3dd27R19 Further, also in this PR, empty string is written by []byte{0x00, 0x00} .

However, I never find reference to this rule in any documents. (ex. ISO/IEC, Apple, Wikileaks, ...) So, I never understand whether this format is a special case of Pascal style string or any other rule.

sunfish-shogi commented 1 year ago

Related: https://github.com/abema/go-mp4/issues/132