From 87db2f24e8eca23664dc23128b8fca2b5d07125d Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 11 Jan 2019 14:10:41 +0100 Subject: demux_edl, cue, mkv: slightly nicer file format indication Instead of just using "edl/" for the file format, report mkv_oc if it's generated from ordered chapters, "cue/" if from .cue, "multi/" if it's from EDL but only for adding separate streams, "dash/" if it's from EDL but only using the DASH hack, and "edl/" for everything else. The EDL variants are mostly special-cased to the variants the ytdl wrapper usually generates. This has no effect other than what the command.c file-format property returns. --- demux/demux_cue.c | 1 + demux/demux_edl.c | 26 ++++++++++++++++++++++---- demux/demux_mkv_timeline.c | 1 + demux/demux_timeline.c | 4 ++-- demux/timeline.c | 1 + demux/timeline.h | 2 ++ 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/demux/demux_cue.c b/demux/demux_cue.c index 8518d928d1..708b742e8f 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -232,6 +232,7 @@ static void build_timeline(struct timeline *tl) tl->num_chapters = track_count; MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par); tl->meta = par->track_layout; + tl->format = "cue"; out: talloc_free(ctx); diff --git a/demux/demux_edl.c b/demux/demux_edl.c index 1f27a971a9..27c1a527f9 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -252,7 +252,8 @@ static void resolve_timestamps(struct tl_part *part, struct demuxer *demuxer) part->offset = demuxer->start_time; } -static bool build_timeline(struct timeline *root, struct tl_parts *parts) +static struct timeline_par *build_timeline(struct timeline *root, + struct tl_parts *parts) { struct timeline_par *tl = talloc_zero(root, struct timeline_par); MP_TARRAY_APPEND(root, root->pars, root->num_pars, tl); @@ -365,11 +366,11 @@ static bool build_timeline(struct timeline *root, struct tl_parts *parts) root->meta = tl->track_layout; tl->num_parts = parts->num_parts; - return true; + return tl; error: root->num_pars = 0; - return false; + return NULL; } // For security, don't allow relative or absolute paths, only plain filenames. @@ -394,13 +395,30 @@ static void build_mpv_edl_timeline(struct timeline *tl) return; } + bool all_dash = true; + bool all_no_clip = true; + bool all_single = true; + for (int n = 0; n < root->num_pars; n++) { struct tl_parts *parts = root->pars[n]; if (!p->allow_any) fix_filenames(parts, tl->demuxer->filename); - if (!build_timeline(tl, parts)) + struct timeline_par *par = build_timeline(tl, parts); + if (!par) break; + all_dash &= par->dash; + all_no_clip &= par->no_clip; + all_single &= par->num_parts == 1; } + + if (all_dash) { + tl->format = "dash"; + } else if (all_no_clip && all_single) { + tl->format = "multi"; + } else { + tl->format = "edl"; + } + talloc_free(root); } diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c index 6d52995e26..60bdf3b673 100644 --- a/demux/demux_mkv_timeline.c +++ b/demux/demux_mkv_timeline.c @@ -630,4 +630,5 @@ void build_ordered_chapter_timeline(struct timeline *tl) tl->chapters = chapters; tl->num_chapters = m->num_ordered_chapters; tl->meta = track_layout; + tl->format = "mkv_oc"; } diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index 1d692d8387..9a1fb8aed4 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -466,8 +466,8 @@ static int d_open(struct demuxer *demuxer, enum demux_check check) demuxer->seekable = true; demuxer->partially_seekable = false; - demuxer->filetype = talloc_asprintf(p, "edl/%s%s", - p->sources[0]->dash ? "dash/" : "", + demuxer->filetype = talloc_asprintf(p, "%s/%s", + p->tl->format, meta->filetype ? meta->filetype : meta->desc->name); reselect_streams(demuxer); diff --git a/demux/timeline.c b/demux/timeline.c index f771155e18..967c20da01 100644 --- a/demux/timeline.c +++ b/demux/timeline.c @@ -16,6 +16,7 @@ struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log, .log = log, .cancel = demuxer->cancel, .demuxer = demuxer, + .format = "unknown", }; demuxer->desc->load_timeline(tl); diff --git a/demux/timeline.h b/demux/timeline.h index 544220358a..d4a7b39403 100644 --- a/demux/timeline.h +++ b/demux/timeline.h @@ -35,6 +35,8 @@ struct timeline { struct mp_log *log; struct mp_cancel *cancel; + const char *format; + // main source, and all other sources (this usually only has special meaning // for memory management; mostly compensates for the lack of refcounting) struct demuxer *demuxer; -- cgit v1.2.3