libavformat mkv checklist - mpv-player/mpv GitHub Wiki
The following things need to be implemented in libavformat’s demuxer to get feature-parity with mpv’s internal demuxer:
- Exporting ordered chapters info. mpv uses this internally:
struct matroska_segment_uid { unsigned char segment[16]; uint64_t edition; }; struct matroska_data { struct matroska_segment_uid uid; // Ordered chapter information if any struct matroska_chapter { uint64_t start; uint64_t end; bool has_segment_uid; struct matroska_segment_uid uid; char *name; } *ordered_chapters; int num_ordered_chapters; };
Actually opening and piecing the segments together is done separately and on a higher level. - Fast checking for ordered chapters segment info
mpv passes these things to a demuxer when opening:
char *demuxer_format; // set to "mkv" int matroska_num_wanted_uids; struct matroska_segment_uid *matroska_wanted_uids; int matroska_wanted_segment;
The first field tells the demuxer that it should fully open the file only if it’s matroska. This can probably be emulated with libavformat (by using the probe API separately). The next 2 fields select the wanted segment/edition. If it’s not in the file, opening is skipped. The last field selects the wanted segment. Most mkv files contain only 1 segment, but some contain multiple, and link them with ordered chapters. This last case is probably one of the most useless Matroska features ever that actually work in Haali. - Subtitle preroll: attempting to grab subtitle packets that start before the seek target, but overlap with the seek target. This is very specific: for example, it is enabled by default when doing absolute hr-seeks in mpv, but needs to be enabled explicitly for normal seeks. This can also make use of the CueDuration element.
- Export timestamp type. Vfw-muxed mkv files use avi-style timestamps (frame number starting from 0). This is different from PTS and DTS, and the mpv demuxer exports this as a per-stream flag.
- Unique packet file positions. Needed for the fast stream switching hack.
- Opus preroll/padding things. (I think libavformat lacks some of these, at least if the AV_PKT_DATA_SKIP_SAMPLES mechanism is used.)
- Distinguishing metadata and file tags: libavformat has, in its utterly misled way of making everything “generic”, no separation between metadata (like extra information not expressible with lavf API), and file tags (like “artist”, and other fields which could be stored as key/value lists in the file and are editable by the user). They’re both stored in “metadata” fields.
- Probing video duration with `—demuxer-mkv-probe-video-duration`
- (Check whether libavformat defers CUE reading even if it shouldn’t, e.g. if there are other header elements at the end of the file that need to be read anyway.)
- mpv’s demuxer appears to be faster. Probably caused by additional parsing in libavformat.
- mpv’s demuxer can seek correctly in some vp9 files, while libavformat breaks (might be general libavformat problem)
- I like that the mpv demuxer warns on incomplete files