mirror of https://github.com/mpv-player/mpv
edl: use start PTS of the source files as default start time
This commit is contained in:
parent
3d065a53fc
commit
d62dad55ef
|
@ -35,8 +35,9 @@
|
||||||
struct tl_part {
|
struct tl_part {
|
||||||
char *filename; // what is stream_open()ed
|
char *filename; // what is stream_open()ed
|
||||||
double offset; // offset into the source file
|
double offset; // offset into the source file
|
||||||
double length; // length of the part (-1 if rest of the file)
|
bool offset_set;
|
||||||
bool chapter_ts;
|
bool chapter_ts;
|
||||||
|
double length; // length of the part (-1 if rest of the file)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tl_parts {
|
struct tl_parts {
|
||||||
|
@ -100,6 +101,7 @@ static struct tl_parts *parse_edl(bstr str)
|
||||||
} else if (bstr_equals0(name, "start")) {
|
} else if (bstr_equals0(name, "start")) {
|
||||||
if (!parse_time(val, &p.offset))
|
if (!parse_time(val, &p.offset))
|
||||||
goto error;
|
goto error;
|
||||||
|
p.offset_set = true;
|
||||||
} else if (bstr_equals0(name, "length")) {
|
} else if (bstr_equals0(name, "length")) {
|
||||||
if (!parse_time(val, &p.length))
|
if (!parse_time(val, &p.length))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -201,6 +203,8 @@ static void resolve_timestamps(struct tl_part *part, struct demuxer *demuxer)
|
||||||
part->offset = start;
|
part->offset = start;
|
||||||
part->length = length;
|
part->length = length;
|
||||||
}
|
}
|
||||||
|
if (!part->offset_set)
|
||||||
|
part->offset = demuxer_get_start_time(demuxer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
||||||
|
@ -219,7 +223,9 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
||||||
resolve_timestamps(part, source);
|
resolve_timestamps(part, source);
|
||||||
|
|
||||||
double len = source_get_length(source);
|
double len = source_get_length(source);
|
||||||
if (len <= 0) {
|
if (len > 0) {
|
||||||
|
len += demuxer_get_start_time(source);
|
||||||
|
} else {
|
||||||
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",
|
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",
|
||||||
part->filename);
|
part->filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue