{demux,player}: expose original and commentary track flags
Those flags were added to the Matroska specification together with the already implemented hearing-impaired and visual-impaired flags. They allow specifying whether a track is a commentary track or in the original language without relying on the free-form track name, which makes consistent tagging and parsing by machines easier. Ref: https://github.com/ietf-wg-cellar/matroska-specification/pull/447 Ref: https://www.rfc-editor.org/rfc/rfc9559#name-original-flag Ref: https://www.rfc-editor.org/rfc/rfc9559#name-commentary-flag
This commit is contained in:
1 parent
f7ad4a5f8f
commit
534b2d2ea6
11 files changed
+46
-2
No files matched your search
@@ -725,6 +725,14 @@ Track Manipulation
|
||||
|
||||
Marks the track as default.
|
||||
|
||||
<original>
|
||||
|
||||
Marks the track as being in the original language.
|
||||
|
||||
<commentary>
|
||||
|
||||
Marks the track as containing commentary.
|
||||
|
||||
<attached-picture> (only for ``video-add``)
|
||||
|
||||
Marks the track as an attached picture, same as ``albumart`` argument
|
||||
|
||||
@@ -90,6 +90,8 @@ elements_matroska = (
|
||||
"FlagForced, 55aa, uint",
|
||||
"FlagHearingImpaired, 55ab, uint",
|
||||
"FlagVisualImpaired, 55ac, uint",
|
||||
"FlagOriginal, 55ae, uint",
|
||||
"FlagCommentary, 55af, uint",
|
||||
"FlagLacing, 9c, uint",
|
||||
"MinCache, 6de7, uint",
|
||||
"MaxCache, 6df8, uint",
|
||||
|
||||
@@ -837,6 +837,10 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
|
||||
sh->visual_impaired_track = true;
|
||||
if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
|
||||
sh->hearing_impaired_track = true;
|
||||
if (st->disposition & AV_DISPOSITION_ORIGINAL)
|
||||
sh->original_track = true;
|
||||
if (st->disposition & AV_DISPOSITION_COMMENT)
|
||||
sh->commentary_track = true;
|
||||
if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
|
||||
sh->still_image = true;
|
||||
if (priv->format_hack.use_stream_ids)
|
||||
@@ -848,6 +852,10 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
|
||||
sh->title = talloc_asprintf(sh, "visual impaired");
|
||||
if (!sh->title && st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
|
||||
sh->title = talloc_asprintf(sh, "hearing impaired");
|
||||
if (!sh->title && st->disposition & AV_DISPOSITION_ORIGINAL)
|
||||
sh->title = talloc_asprintf(sh, "original");
|
||||
if (!sh->title && st->disposition & AV_DISPOSITION_COMMENT)
|
||||
sh->title = talloc_asprintf(sh, "commentary");
|
||||
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
|
||||
if (lang && lang->value && strcmp(lang->value, "und") != 0)
|
||||
sh->lang = talloc_strdup(sh, lang->value);
|
||||
|
||||
@@ -131,6 +131,8 @@ typedef struct mkv_track {
|
||||
int forced_track;
|
||||
int visual_impaired_track;
|
||||
int hearing_impaired_track;
|
||||
int original_track;
|
||||
int commentary_track;
|
||||
|
||||
unsigned char *private_data;
|
||||
unsigned int private_size;
|
||||
@@ -964,6 +966,16 @@ static void parse_trackentry(struct demuxer *demuxer,
|
||||
MP_DBG(demuxer, "| + Hearing-Impaired flag: %d\n", track->hearing_impaired_track);
|
||||
}
|
||||
|
||||
if (entry->n_flag_original) {
|
||||
track->original_track = entry->flag_original;
|
||||
MP_DBG(demuxer, "| + Original flag: %d\n", track->original_track);
|
||||
}
|
||||
|
||||
if (entry->n_flag_commentary) {
|
||||
track->commentary_track = entry->flag_commentary;
|
||||
MP_DBG(demuxer, "| + Commentary flag: %d\n", track->commentary_track);
|
||||
}
|
||||
|
||||
if (entry->n_default_duration) {
|
||||
track->default_duration = entry->default_duration / 1e9;
|
||||
if (entry->default_duration == 0) {
|
||||
@@ -1552,6 +1564,8 @@ static void init_track(demuxer_t *demuxer, mkv_track_t *track,
|
||||
sh->forced_track = track->forced_track;
|
||||
sh->visual_impaired_track = track->visual_impaired_track;
|
||||
sh->hearing_impaired_track = track->hearing_impaired_track;
|
||||
sh->original_track = track->original_track;
|
||||
sh->commentary_track = track->commentary_track;
|
||||
}
|
||||
|
||||
static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track);
|
||||
|
||||
@@ -49,6 +49,8 @@ struct sh_stream {
|
||||
bool dependent_track; // container dependent track flag
|
||||
bool visual_impaired_track; // container flag
|
||||
bool hearing_impaired_track;// container flag
|
||||
bool original_track; // container flag
|
||||
bool commentary_track; // container flag
|
||||
bool image; // video stream is an image
|
||||
bool still_image; // video consists of multiple sparse still images
|
||||
int hls_bitrate;
|
||||
|
||||
@@ -2054,6 +2054,8 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
|
||||
{"dependent", SUB_PROP_BOOL(track->dependent_track)},
|
||||
{"visual-impaired", SUB_PROP_BOOL(track->visual_impaired_track)},
|
||||
{"hearing-impaired", SUB_PROP_BOOL(track->hearing_impaired_track)},
|
||||
{"original", SUB_PROP_BOOL(track->original_track)},
|
||||
{"commentary", SUB_PROP_BOOL(track->commentary_track)},
|
||||
{"external", SUB_PROP_BOOL(track->is_external)},
|
||||
{"selected", SUB_PROP_BOOL(track->selected)},
|
||||
{"main-selection", SUB_PROP_INT(order), .unavailable = order < 0},
|
||||
|
||||
@@ -120,6 +120,7 @@ struct track {
|
||||
char *title;
|
||||
bool default_track, forced_track, dependent_track;
|
||||
bool visual_impaired_track, hearing_impaired_track;
|
||||
bool original_track, commentary_track;
|
||||
bool forced_select; // if the track was selected because it is forced
|
||||
bool image;
|
||||
bool attached_picture;
|
||||
|
||||
@@ -431,6 +431,8 @@ static struct track *add_stream_track(struct MPContext *mpctx,
|
||||
.dependent_track = stream->dependent_track,
|
||||
.visual_impaired_track = stream->visual_impaired_track,
|
||||
.hearing_impaired_track = stream->hearing_impaired_track,
|
||||
.original_track = stream->original_track,
|
||||
.commentary_track = stream->commentary_track,
|
||||
.image = stream->image,
|
||||
.attached_picture = stream->attached_picture != NULL,
|
||||
.lang = stream->lang,
|
||||
|
||||
@@ -112,7 +112,7 @@ local function format_flags(track)
|
||||
|
||||
for _, flag in ipairs({
|
||||
"default", "forced", "dependent", "visual-impaired", "hearing-impaired",
|
||||
"image", "external"
|
||||
"original", "commentary", "image", "external"
|
||||
}) do
|
||||
if track[flag] then
|
||||
flags = flags .. flag .. " "
|
||||
|
||||
@@ -1248,7 +1248,8 @@ local function add_track(c, t, i)
|
||||
append(c, t["external-filename"], {prefix="File:"})
|
||||
append(c, "", {prefix="Flags:"})
|
||||
local flags = {"default", "forced", "dependent", "visual-impaired",
|
||||
"hearing-impaired", "image", "albumart", "external"}
|
||||
"hearing-impaired", "original", "commentary", "image",
|
||||
"albumart", "external"}
|
||||
local any = false
|
||||
for _, flag in ipairs(flags) do
|
||||
if t[flag] then
|
||||
|
||||
@@ -416,6 +416,10 @@ char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang)
|
||||
ADD_FLAG(ctx, dst, "visual-impaired", first);
|
||||
if (t->hearing_impaired_track)
|
||||
ADD_FLAG(ctx, dst, "hearing-impaired", first);
|
||||
if (t->original_track)
|
||||
ADD_FLAG(ctx, dst, "original", first);
|
||||
if (t->commentary_track)
|
||||
ADD_FLAG(ctx, dst, "commentary", first);
|
||||
if (t->is_external)
|
||||
ADD_FLAG(ctx, dst, "external", first);
|
||||
if (!first)
|
||||
|
||||
Reference in new issue
Block a user