summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-19 00:06:00 +0100
committerwm4 <wm4@nowhere>2014-02-19 00:06:00 +0100
commite6f543ebec5539853cad0bb449ae441a14bb27c3 (patch)
treee7781cef3f07946f4bfe382cf0661b57e93356f1 /player
parentd29661af8a3bbb134ded311f36f38522c6bf3a63 (diff)
downloadmpv-e6f543ebec5539853cad0bb449ae441a14bb27c3.tar.bz2
mpv-e6f543ebec5539853cad0bb449ae441a14bb27c3.tar.xz
edl: extend with chapter timestamps
Example see edl-mpv.rst. What is this useful for? No clue...
Diffstat (limited to 'player')
-rw-r--r--player/timeline/tl_mpv_edl.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/player/timeline/tl_mpv_edl.c b/player/timeline/tl_mpv_edl.c
index 2cc6050d08..94d46e03a5 100644
--- a/player/timeline/tl_mpv_edl.c
+++ b/player/timeline/tl_mpv_edl.c
@@ -36,6 +36,7 @@ struct tl_part {
char *filename; // what is stream_open()ed
double offset; // offset into the source file
double length; // length of the part (-1 if rest of the file)
+ bool chapter_ts;
};
struct tl_parts {
@@ -102,6 +103,9 @@ static struct tl_parts *parse_edl(bstr str)
} else if (bstr_equals0(name, "length")) {
if (!parse_time(val, &p.length))
goto error;
+ } else if (bstr_equals0(name, "timestamps")) {
+ if (bstr_equals0(val, "chapters"))
+ p.chapter_ts = true;
}
nparam++;
if (!bstr_eatstart0(&str, ","))
@@ -182,6 +186,21 @@ static double source_get_length(struct demuxer *demuxer)
return time;
}
+static void resolve_timestamps(struct tl_part *part, struct demuxer *demuxer)
+{
+ if (part->chapter_ts) {
+ double start = demuxer_chapter_time(demuxer, part->offset);
+ double length = part->length;
+ double end = length;
+ if (end >= 0)
+ end = demuxer_chapter_time(demuxer, part->offset + part->length);
+ if (end >= 0 && start >= 0)
+ length = end - start;
+ part->offset = start;
+ part->length = length;
+ }
+}
+
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
{
struct chapter *chapters = talloc_new(NULL);
@@ -195,6 +214,8 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
if (!source)
goto error;
+ resolve_timestamps(part, source);
+
double len = source_get_length(source);
if (len <= 0) {
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",