summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-08 21:18:35 +0100
committerwm4 <wm4@nowhere>2016-02-08 21:18:35 +0100
commit3d9e1ad363e9b992bae59773c08bfb7bd3b1c796 (patch)
tree641254fc1e090245a789687f64664b2bdec582d1
parent09d61032cac27ce12e1b858b531150ac89efe424 (diff)
downloadmpv-3d9e1ad363e9b992bae59773c08bfb7bd3b1c796.tar.bz2
mpv-3d9e1ad363e9b992bae59773c08bfb7bd3b1c796.tar.xz
player: add --external-file option
Mostly intended for use with --lavfi-complex.
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--player/loadfile.c26
4 files changed, 19 insertions, 14 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 97f84c6219..3b2c3ce3e0 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3554,6 +3554,11 @@ Miscellaneous
for scripts which want to set a title, without overriding the user's
setting in ``--title``.
+``--external-file=<filename>``
+ Add all tracks from the given file. Unlike ``--sub-file`` and
+ ``--audio-file``, this includes all tracks, and does not cause default
+ stream selection over the "proper" file.
+
``--lavfi-complex=<string>``
Set a "complex" libavfilter filter, which means a single filter graph can
take input from multiple source audio and video tracks. The graph can result
diff --git a/options/options.c b/options/options.c
index 4352b6ceed..e1be68dc07 100644
--- a/options/options.c
+++ b/options/options.c
@@ -336,6 +336,7 @@ const m_option_t mp_opts[] = {
OPT_STRING_APPEND_LIST("sub-file", sub_name, M_OPT_FILE),
OPT_PATHLIST("sub-paths", sub_paths, 0),
OPT_PATHLIST("audio-file-paths", audiofile_paths, 0),
+ OPT_STRING_APPEND_LIST("external-file", external_files, M_OPT_FILE),
OPT_STRING("sub-codepage", sub_cp, 0),
OPT_FLOAT("sub-delay", sub_delay, 0),
OPT_FLOAT("sub-fps", sub_fps, 0),
diff --git a/options/options.h b/options/options.h
index 488823ca15..95268cd522 100644
--- a/options/options.h
+++ b/options/options.h
@@ -240,6 +240,7 @@ typedef struct MPOpts {
char **sub_name;
char **sub_paths;
char **audiofile_paths;
+ char **external_files;
int sub_auto;
int audiofile_auto;
int osd_bar_visible;
diff --git a/player/loadfile.c b/player/loadfile.c
index 7ed4cb6201..14ea719e62 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -696,6 +696,8 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
return true;
}
+// Add the given file as additional track. Only tracks of type "filter" are
+// included; pass STREAM_TYPE_COUNT to disable filtering.
struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
enum stream_type filter)
{
@@ -729,12 +731,14 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
struct track *first = NULL;
for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
struct sh_stream *sh = demux_get_stream(demuxer, n);
- if (sh->type == filter) {
+ if (filter == STREAM_TYPE_COUNT || sh->type == filter) {
struct track *t = add_stream_track(mpctx, demuxer, sh, false);
t->is_external = true;
t->title = talloc_strdup(t, mp_basename(disp_filename));
t->external_filename = talloc_strdup(t, filename);
first = t;
+ // --external-file special semantics
+ t->no_default = filter == STREAM_TYPE_COUNT;
}
}
if (!first) {
@@ -753,18 +757,11 @@ err_out:
return false;
}
-static void open_audiofiles_from_options(struct MPContext *mpctx)
+static void open_external_files(struct MPContext *mpctx, char **files,
+ enum stream_type filter)
{
- struct MPOpts *opts = mpctx->opts;
- for (int n = 0; opts->audio_files && opts->audio_files[n]; n++)
- mp_add_external_file(mpctx, opts->audio_files[n], STREAM_AUDIO);
-}
-
-static void open_subtitles_from_options(struct MPContext *mpctx)
-{
- struct MPOpts *opts = mpctx->opts;
- for (int i = 0; opts->sub_name && opts->sub_name[i] != NULL; i++)
- mp_add_external_file(mpctx, opts->sub_name[i], STREAM_SUB);
+ for (int n = 0; files && files[n]; n++)
+ mp_add_external_file(mpctx, files[n], filter);
}
void autoload_external_files(struct MPContext *mpctx)
@@ -1247,8 +1244,9 @@ reopen_file:
mpctx->timeline_part = mpctx->num_timeline_parts;
timeline_switch_to_time(mpctx, 0);
- open_subtitles_from_options(mpctx);
- open_audiofiles_from_options(mpctx);
+ open_external_files(mpctx, opts->audio_files, STREAM_AUDIO);
+ open_external_files(mpctx, opts->sub_name, STREAM_SUB);
+ open_external_files(mpctx, opts->external_files, STREAM_TYPE_COUNT);
autoload_external_files(mpctx);
check_previous_track_selection(mpctx);