Skip to content

support ftypmp42 format - #11

Open
PKiman wants to merge 5 commits into
ClementBeal:mainfrom
PKiman:ftypmp42_support
Open

support ftypmp42 format#11
PKiman wants to merge 5 commits into
ClementBeal:mainfrom
PKiman:ftypmp42_support

Conversation

@PKiman

@PKiman PKiman commented May 22, 2024

Copy link
Copy Markdown
Contributor

Hi,

I found an issue with audio recordings created by Android devices.
iOS is fine.

A sample file has been added to test.
readMetadata.duration is null.

test/mp4/track_ftypmp42.m4a

It appears that the meta box size differs.
Files with ftypmp42 header have 4 bytes meta box size.
Files with ftypM4A header have 8 bytes meta box size.

At the moment only duration works. Other meta data are null for ftypmp42 files e.g. sampleRate.

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

@ClementBeal

Copy link
Copy Markdown
Owner

Hi!

Thank you for the PR! I reviewed it and I don't notice any issue and it works! I'll try to find more mp4 to check.

With MusicBrainz, I set some metadata like the title or the album name and it works as well.

To be sure, the problem is the parsing of the ftyp was wrong, isn't it?

@PKiman

PKiman commented May 23, 2024

Copy link
Copy Markdown
Contributor Author

Yes, there are different specs for ftyp.
Some specs are ISO normed, some are proprietary (Apple).
https://www.ftyps.com

This command was useful for debugging and understanding how type box parsing works.

ffprobe -v trace test/mp4/track_ftypmp42.m4a 

[file @ 0x7fdce5c04540] Setting default whitelist 'file,crypto,data'
Probing mov,mp4,m4a,3gp,3g2,mj2 score:100 size:2048
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] type:'ftyp' parent:'root' sz: 24 8 15439
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] ISO: File Type Major Brand: mp42
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] type:'moov' parent:'root' sz: 885 32 15439
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] type:'mvhd' parent:'moov' sz: 108 8 877
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] time scale = 10000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] type:'meta' parent:'moov' sz: 118 116 877
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdce5c04100] type:'hdlr' parent:'meta' sz: 33 8 110

https://www.file-recovery.com/m4a-signature-format.htm
https://dev.to/alfg/a-quick-dive-into-mp4-57fo

@PKiman

PKiman commented May 23, 2024

Copy link
Copy Markdown
Contributor Author

Obviously implementations use magic byte patterns and apply different specifications.
There is no general method for parsing an mp4 file.

https://github.com/discord/lilliput/blob/b13db14b20fd82e580836108c73235686b6ab820/lilliput.go#L24

@ClementBeal

Copy link
Copy Markdown
Owner

Let's resolve the merge conflict and then I merge your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants