summaryrefslogtreecommitdiffstats
path: root/mpvcore/player/timeline/tl_matroska.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-14 21:52:37 +0100
committerwm4 <wm4@nowhere>2013-12-14 21:52:37 +0100
commit2f49fbff93d76950c441daef76afb3adb9078429 (patch)
tree59cfa3499143538c218da1d470bf85ad4da04ee5 /mpvcore/player/timeline/tl_matroska.c
parent7f3eda41d940bb0575615c3af4fc64793220d478 (diff)
downloadmpv-2f49fbff93d76950c441daef76afb3adb9078429.tar.bz2
mpv-2f49fbff93d76950c441daef76afb3adb9078429.tar.xz
matroska: add --ordered-chapters-files option
This option takes a playlist. The playlist will then be used as list of potential segment files for use with ordered chapters.
Diffstat (limited to 'mpvcore/player/timeline/tl_matroska.c')
-rw-r--r--mpvcore/player/timeline/tl_matroska.c18
1 files changed, 16 insertions, 2 deletions
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;
}