Skip to content

Fragmented MP4 audio udta box metadata parsing #2084

@nift4

Description

@nift4

[REQUIRED] Use case description

Today, a user complained about metadata extraction failing for all his .m4a files. After I got the files, I noticed his collection consists entirely of fragmented, dash/iso6mp41-branded files. I was able to confirm that ExoPlayer extracts no metadata at all from his file but seems to work fine with non-fragmented M4A files. After some more digging I noticed the udta/ilst parsing codepath only seems to be triggered from Mp4Extractor but never FragmentedMp4Extractor. ffprobe and exiftool are able to parse both files no issues, and after converting the file to non-fragmented with ffmpeg -i in.m4a -map_metadata 0:s:a:0 -map_metadata 0 -c copy out.m4a ExoPlayer was able to read the metadata.

Proposed solution

Implement parsing in FragmentedMp4Extractor, perhaps similar to this method used by Mp4Extractor:

private static Metadata parseUdtaMeta(ParsableByteArray meta, int limit) {
meta.skipBytes(Mp4Box.HEADER_SIZE);
maybeSkipRemainingMetaBoxHeaderBytes(meta);
while (meta.getPosition() < limit) {
int atomPosition = meta.getPosition();
int atomSize = meta.readInt();
int atomType = meta.readInt();
if (atomType == Mp4Box.TYPE_ilst) {
meta.setPosition(atomPosition);
return parseIlst(meta, atomPosition + atomSize);
}
meta.setPosition(atomPosition + atomSize);
}
return null;
}

Unfortunately I have no prior knowledge of this format and don't have the time to contribute this in the forseeable future.

Alternatives considered

Tell all users to re-mux their files to non-fragmented MP4, but they don't seem to like that answer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions