mirror of
https://github.com/mpv-player/mpv
synced 2025-03-23 03:37:27 +00:00
timeline: reject mplayer2 EDL files, change EDL header
This was forgotten when the parser for mplayer2 EDL files was removed. Change the header of the mpv EDL format to include a '#', so a naive parser could skip the header as comment. (Maybe this is questionable; on the other hand, if it can be simpler, why not.) Also, strip the header in demux_edl.c before passing on the data, so the header check doesn't need to be duplicated in tl_mpv_edl.c.
This commit is contained in:
parent
287d2e0603
commit
d585382f0e
@ -7,7 +7,7 @@ segment, and consists of source file, source offset, and segment length.
|
||||
|
||||
For example::
|
||||
|
||||
mpv EDL v0
|
||||
# mpv EDL v0
|
||||
f1.mkv,10,20
|
||||
f2.mkv
|
||||
f1.mkv,40,10
|
||||
@ -21,6 +21,7 @@ virtual EDL file appears as a single file, instead as a playlist.
|
||||
|
||||
The general simplified syntax is:
|
||||
|
||||
# mpv EDL v0
|
||||
<filename>
|
||||
<filename>,<start in seconds>,<length in seconds>
|
||||
|
||||
@ -40,7 +41,7 @@ Syntax of mpv EDL files
|
||||
Generally, the format is relatively strict. No superfluous whitespace (except
|
||||
empty lines and commented lines) are allowed. You must use UNIX line breaks.
|
||||
|
||||
The first line in the file must be ``mpv EDL v0``. This designates that the
|
||||
The first line in the file must be ``# mpv EDL v0``. This designates that the
|
||||
file uses format version 0, which is not frozen yet and may change any time.
|
||||
(If you need a stable EDL file format, make a feature request. Likewise, if
|
||||
you have suggestions for improvements, it's not too late yet.)
|
||||
@ -84,7 +85,7 @@ implicitly uses the name ``start``.
|
||||
|
||||
Example::
|
||||
|
||||
mpv EDL v0
|
||||
# mpv EDL v0
|
||||
%18%filename,with,.mkv,10,length=20,param3=%13%value,escaped,param4=value2
|
||||
|
||||
this sets ``file`` to ``filename,with,.mkv``, ``start`` to ``10``, ``length``
|
||||
|
@ -25,27 +25,24 @@
|
||||
#include "demux.h"
|
||||
#include "stream/stream.h"
|
||||
|
||||
static bool test_header(struct stream *s, char *header)
|
||||
{
|
||||
return bstr_equals0(stream_peek(s, strlen(header)), header);
|
||||
}
|
||||
#define HEADER "# mpv EDL v0\n"
|
||||
|
||||
// Note: the real work is handled in tl_mpv_edl.c.
|
||||
static int try_open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
{
|
||||
struct stream *s = demuxer->stream;
|
||||
if (s->uncached_type == STREAMTYPE_EDL) {
|
||||
demuxer->file_contents = bstr0(s->url);
|
||||
demuxer->file_contents = bstr0(s->path);
|
||||
return 0;
|
||||
}
|
||||
if (check >= DEMUX_CHECK_UNSAFE) {
|
||||
if (!test_header(s, "mplayer EDL file") &&
|
||||
!test_header(s, "mpv EDL v0\n"))
|
||||
if (!bstr_equals0(stream_peek(s, strlen(HEADER)), HEADER))
|
||||
return -1;
|
||||
}
|
||||
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000);
|
||||
if (demuxer->file_contents.start == NULL)
|
||||
return -1;
|
||||
bstr_eatstart0(&demuxer->file_contents, HEADER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -428,8 +428,6 @@ void update_subtitles(struct MPContext *mpctx);
|
||||
void build_ordered_chapter_timeline(struct MPContext *mpctx);
|
||||
// timeline/tl_mpv_edl.c
|
||||
void build_mpv_edl_timeline(struct MPContext *mpctx);
|
||||
// timeline/tl_edl.c
|
||||
void build_edl_timeline(struct MPContext *mpctx);
|
||||
// timeline/tl_cue.c
|
||||
void build_cue_timeline(struct MPContext *mpctx);
|
||||
|
||||
|
@ -56,16 +56,14 @@ static bool parse_time(bstr str, double *out_time)
|
||||
}
|
||||
|
||||
/* Returns a list of parts, or NULL on parse error.
|
||||
* Syntax:
|
||||
* url ::= ['edl://'|'mpv EDL v0\n'] <entry> ( (';' | '\n') <entry> )*
|
||||
* Syntax (without file header or URI prefix):
|
||||
* url ::= <entry> ( (';' | '\n') <entry> )*
|
||||
* entry ::= <param> ( <param> ',' )*
|
||||
* param ::= [<string> '='] (<string> | '%' <number> '%' <bytes>)
|
||||
*/
|
||||
static struct tl_parts *parse_edl(bstr str)
|
||||
{
|
||||
struct tl_parts *tl = talloc_zero(NULL, struct tl_parts);
|
||||
if (!bstr_eatstart0(&str, "edl://"))
|
||||
bstr_eatstart0(&str, "mpv EDL v0\n");
|
||||
while (str.len) {
|
||||
if (bstr_eatstart0(&str, "#"))
|
||||
bstr_split_tok(str, "\n", &(bstr){0}, &str);
|
||||
|
Loading…
Reference in New Issue
Block a user