summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst9
-rw-r--r--mpvcore/options.c1
-rw-r--r--mpvcore/options.h1
-rw-r--r--mpvcore/player/main.c3
-rw-r--r--mpvcore/player/misc.c23
-rw-r--r--mpvcore/player/mp_core.h1
6 files changed, 38 insertions, 0 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 5e67f36278..a9f0656e59 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1292,6 +1292,15 @@ OPTIONS
``--media-keys``, ``--no-media-keys``
OSX only: Enabled by default. Enables/disable media keys support.
+``--merge-files``
+ Pretend that all files passed to mpv are concatenated into a single, big
+ file. This uses timeline/EDL support internally. Note that this won't work
+ for ordered chapter files or quvi-resolved URLs (such as youtube links).
+
+ This option is interpreted at program start, and doesn't affect for
+ example files or playlists loaded with the ``loadfile`` or ``loadlist``
+ commands.
+
``--mf=<option1:option2:...>``
Used when decoding from multiple PNG or JPEG files with ``mf://``.
diff --git a/mpvcore/options.c b/mpvcore/options.c
index e8c82c447f..efb6b79569 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -694,6 +694,7 @@ const m_option_t mp_opts[] = {
OPT_DOUBLE("chapter-seek-threshold", chapter_seek_threshold, 0),
OPT_FLAG("load-unsafe-playlists", load_unsafe_playlists, 0),
+ OPT_FLAG("merge-files", merge_files, 0),
// a-v sync stuff:
OPT_FLAG("correct-pts", correct_pts, 0),
diff --git a/mpvcore/options.h b/mpvcore/options.h
index e6df87f4b8..62090cedd4 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -94,6 +94,7 @@ typedef struct MPOpts {
int chapter_merge_threshold;
double chapter_seek_threshold;
int load_unsafe_playlists;
+ int merge_files;
int quiet;
int load_config;
int use_filedir_conf;
diff --git a/mpvcore/player/main.c b/mpvcore/player/main.c
index 34383f4264..4119e244c3 100644
--- a/mpvcore/player/main.c
+++ b/mpvcore/player/main.c
@@ -419,6 +419,9 @@ static int mpv_main(int argc, char *argv[])
if (opts->shuffle)
playlist_shuffle(mpctx->playlist);
+ if (opts->merge_files)
+ merge_playlist_files(mpctx->playlist);
+
mpctx->playlist->current = mp_resume_playlist(mpctx->playlist, opts);
if (!mpctx->playlist->current)
mpctx->playlist->current = mpctx->playlist->first;
diff --git a/mpvcore/player/misc.c b/mpvcore/player/misc.c
index be42d76447..548e2c7967 100644
--- a/mpvcore/player/misc.c
+++ b/mpvcore/player/misc.c
@@ -32,6 +32,7 @@
#include "mpvcore/mp_common.h"
#include "mpvcore/resolve.h"
#include "mpvcore/encode.h"
+#include "mpvcore/playlist.h"
#include "mpvcore/input/input.h"
#include "audio/out/ao.h"
@@ -184,3 +185,25 @@ void stream_dump(struct MPContext *mpctx)
}
}
}
+
+void merge_playlist_files(struct playlist *pl)
+{
+ if (!pl->first)
+ return;
+ char *edl = talloc_strdup(NULL, "edl://");
+ for (struct playlist_entry *e = pl->first; e; e = e->next) {
+ if (e != pl->first)
+ edl = talloc_strdup_append_buffer(edl, ";");
+ // Escape if needed
+ if (e->filename[strcspn(e->filename, "=%,;\n")] ||
+ bstr_strip(bstr0(e->filename)).len != strlen(e->filename))
+ {
+ // %length%
+ edl = talloc_asprintf_append_buffer(edl, "%%%d%%", strlen(e->filename));
+ }
+ edl = talloc_strdup_append_buffer(edl, e->filename);
+ }
+ playlist_clear(pl);
+ playlist_add_file(pl, edl);
+ talloc_free(edl);
+}
diff --git a/mpvcore/player/mp_core.h b/mpvcore/player/mp_core.h
index 4e0dede812..2ea65f54be 100644
--- a/mpvcore/player/mp_core.h
+++ b/mpvcore/player/mp_core.h
@@ -376,6 +376,7 @@ double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t,
double fallback_time);
double get_play_end_pts(struct MPContext *mpctx);
double get_relative_time(struct MPContext *mpctx);
+void merge_playlist_files(struct playlist *pl);
int mp_get_cache_percent(struct MPContext *mpctx);
bool mp_get_cache_idle(struct MPContext *mpctx);
void update_window_title(struct MPContext *mpctx, bool force);