From b230525352a8c43f00497774f81569c4ea026d6b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Jan 2019 08:43:58 +0100 Subject: demux_edl: add a special header to disable chapter generation A bit of a hack. --- DOCS/edl-mpv.rst | 12 ++++++++++++ demux/demux_edl.c | 28 +++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/DOCS/edl-mpv.rst b/DOCS/edl-mpv.rst index cfec52c1bc..cf0d7ffddb 100644 --- a/DOCS/edl-mpv.rst +++ b/DOCS/edl-mpv.rst @@ -100,6 +100,18 @@ entries affect all other file entries in the EDL file. Their format is highly implementation specific. They should generally follow the file header, and come before any file entries. +Disabling chapter generation and copying +======================================== + +By default, chapters from the source ranges are copied to the virtual file's +chapters. Also, a chapter is inserted after each range. This can be disabled +with the ``no_chapters`` header. + +Example:: + + !no_chapters + + MP4 DASH ======== diff --git a/demux/demux_edl.c b/demux/demux_edl.c index 98e31a79f2..882af417e7 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -45,6 +45,7 @@ struct tl_part { }; struct tl_parts { + bool disable_chapters; bool dash; char *init_fragment_url; struct tl_part *parts; @@ -153,6 +154,8 @@ static struct tl_parts *parse_edl(bstr str) struct tl_parts *ntl = talloc_zero(tl, struct tl_parts); tl->next = ntl; tl = ntl; + } else if (bstr_equals0(f_type, "no_chapters")) { + tl->disable_chapters = true; } else { goto error; } @@ -309,17 +312,20 @@ static void build_timeline(struct timeline *tl, struct tl_parts *parts) } } - // Add a chapter between each file. - struct demux_chapter ch = { - .pts = starttime, - .metadata = talloc_zero(tl, struct mp_tags), - }; - mp_tags_set_str(ch.metadata, "title", part->title ? part->title : part->filename); - MP_TARRAY_APPEND(tl, tl->chapters, tl->num_chapters, ch); - - // Also copy the source file's chapters for the relevant parts - copy_chapters(&tl->chapters, &tl->num_chapters, source, part->offset, - part->length, starttime); + if (!parts->disable_chapters) { + // Add a chapter between each file. + struct demux_chapter ch = { + .pts = starttime, + .metadata = talloc_zero(tl, struct mp_tags), + }; + mp_tags_set_str(ch.metadata, "title", + part->title ? part->title : part->filename); + MP_TARRAY_APPEND(tl, tl->chapters, tl->num_chapters, ch); + + // Also copy the source file's chapters for the relevant parts + copy_chapters(&tl->chapters, &tl->num_chapters, source, + part->offset, part->length, starttime); + } } tl->parts[n] = (struct timeline_part) { -- cgit v1.2.3