summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/options.c1
-rw-r--r--mpvcore/options.h1
-rw-r--r--mpvcore/player/timeline/tl_matroska.c18
3 files changed, 18 insertions, 2 deletions
diff --git a/mpvcore/options.c b/mpvcore/options.c
index de7183014f..1a76aa9bf3 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -684,6 +684,7 @@ const m_option_t mp_opts[] = {
OPT_FLAG("save-position-on-quit", position_save_on_quit, 0),
OPT_FLAG("ordered-chapters", ordered_chapters, 0),
+ OPT_STRING("ordered-chapters-files", ordered_chapters_files, 0),
OPT_INTRANGE("chapter-merge-threshold", chapter_merge_threshold, 0, 0, 10000),
OPT_DOUBLE("chapter-seek-threshold", chapter_seek_threshold, 0),
diff --git a/mpvcore/options.h b/mpvcore/options.h
index f421fcccb5..1544e37edb 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -91,6 +91,7 @@ typedef struct MPOpts {
int loop_times;
int shuffle;
int ordered_chapters;
+ char *ordered_chapters_files;
int chapter_merge_threshold;
double chapter_seek_threshold;
int load_unsafe_playlists;
diff --git a/mpvcore/player/timeline/tl_matroska.c b/mpvcore/player/timeline/tl_matroska.c
index 2ecc292a84..fa0e315fc5 100644
--- a/mpvcore/player/timeline/tl_matroska.c
+++ b/mpvcore/player/timeline/tl_matroska.c
@@ -36,6 +36,8 @@
#include "mpvcore/path.h"
#include "mpvcore/bstr.h"
#include "mpvcore/mp_common.h"
+#include "mpvcore/playlist.h"
+#include "mpvcore/playlist_parser.h"
#include "stream/stream.h"
struct find_entry {
@@ -250,13 +252,23 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
int *num_sources,
struct matroska_segment_uid **uids)
{
+ struct MPOpts *opts = mpctx->opts;
+ void *tmp = talloc_new(NULL);
int num_filenames = 0;
char **filenames = NULL;
if (*num_sources > 1) {
char *main_filename = mpctx->demuxer->filename;
mp_msg(MSGT_CPLAYER, MSGL_INFO, "This file references data from "
"other sources.\n");
- if (mpctx->demuxer->stream->uncached_type != STREAMTYPE_FILE) {
+ if (opts->ordered_chapters_files && opts->ordered_chapters_files[0]) {
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Loading references from '%s'.\n",
+ opts->ordered_chapters_files);
+ struct playlist *pl =
+ playlist_parse_file(opts->ordered_chapters_files, opts);
+ talloc_steal(tmp, pl);
+ for (struct playlist_entry *e = pl->first; e; e = e->next)
+ MP_TARRAY_APPEND(tmp, filenames, num_filenames, e->filename);
+ } else if (mpctx->demuxer->stream->uncached_type != STREAMTYPE_FILE) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Playback source is not a "
"normal disk file. Will not search for related files.\n");
} else {
@@ -264,6 +276,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
"same directory to find referenced sources.\n");
filenames = find_files(main_filename, ".mkv");
num_filenames = MP_TALLOC_ELEMS(filenames);
+ talloc_steal(tmp, filenames);
}
// Possibly get further segments appended to the first segment
check_file(mpctx, sources, num_sources, uids, main_filename, 1);
@@ -281,7 +294,6 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
/* Loop while we have new sources to look for. */
} while (old_source_count != *num_sources);
- talloc_free(filenames);
if (missing(*sources, *num_sources)) {
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Failed to find ordered chapter part!\n"
"There will be parts MISSING from the video!\n");
@@ -296,6 +308,8 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
}
*num_sources = j;
}
+
+ talloc_free(tmp);
return *num_sources;
}