Add support for parsing chapters from MKV files#3144
Add support for parsing chapters from MKV files#3144tymmesyde wants to merge 6 commits intoandroidx:mainfrom
Conversation
And some other stylistic changes
icbaker
left a comment
There was a problem hiding this comment.
I can't work out how to delete the stale comment made against an old copy of the code, sorry for the duplication.
| private static final int ID_CHAPTER_TIME_START = 0x91; | ||
| private static final int ID_CHAPTER_TIME_END = 0x92; | ||
| private static final int ID_CHAPTER_TRACK = 0x8F; | ||
| private static final int ID_CHAPTER_TRACK_UID = 0x89; |
There was a problem hiding this comment.
I didn't find this documented in https://datatracker.ietf.org/doc/rfc9559/ - where is this defined?
There was a problem hiding this comment.
I don't see it there, i followed this spec: https://www.matroska.org/technical/elements.html
So i guess it's not a RFC standard? Should i remove related logic?
There was a problem hiding this comment.
It is specified in the sources tho: https://github.com/ietf-wg-cellar/matroska-specification/blob/master/ebml_matroska.xml#L1521, probably was not deployed to the webiste
| getCurrentTrack(id).number = (int) value; | ||
| break; | ||
| case ID_TRACK_UID: | ||
| getCurrentTrack(id).uid = (int) value; |
There was a problem hiding this comment.
This is documented in https://datatracker.ietf.org/doc/rfc9559/ with range: not 0 (1-18446744073709551615) which I think means:
- We should use
longhere (since18446744073709551615 = 2^64 - 1- so actually even Java signedlongkinda isn't large enough if you consider signedness - but better thanint) - We should use
0as the 'unset' value, notFormat.NO_VALUEwhich is-1in Java signed int math, which is18446744073709551615as a 64-bit unsigned int (i.e. a technically valid value).
| if (!chapter.flagHidden | ||
| && (chapter.trackUid == Format.NO_VALUE || chapter.trackUid == uid)) { | ||
| long startTimeMs = | ||
| chapter.timeStartNs != Format.NO_VALUE |
There was a problem hiding this comment.
it is defaulted to C.TIME_UNSET but you're comparing it with Format.NO_VALUE
| ? TimeUnit.NANOSECONDS.toMillis(chapter.timeStartNs) | ||
| : 0L; | ||
| long endTimeMs = | ||
| chapter.timeEndNs != Format.NO_VALUE |
Hi,
this include changes to support parsing MKV chapters using the recent changes to introduce metadata Chapter interface
This is already implemented for MP4: Nero & QuickTime
Used this doc as reference: https://www.matroska.org/technical/elements.html
Added
sample_with_chapters.mkvformkvSample_withChapterstestGenerated with: