diff options
authorwm4 <wm4@nowhere>2018-01-06 17:49:37 +0100
committerKevin Mitchell <>2018-01-06 14:42:22 -0800
commit34cf655ddd99a67af0d1899499c14c4617236352 (patch)
parentcf8855cd2efb2828441dde19a713a34af20b4bc5 (diff)
player: strictly never autoselect tracks from --external-files
Before this commit, some autoselection of tracks coming from files loaded with --external-files was still done. This commit removes all of it, and the only way to select a track is via the explicit stream selection options like --vid/--sid/--aid. I think this was always the original intention. The change could in theory still unintentionally surprise some users, so add a changelog entry. This does not affect --audio-file/--sub-file, even if these contain mismatching track types. E.g. if audio files passed to --audio-file contain subtitles, these should still be selected. Past feature requests indicate that users want this.
4 files changed, 9 insertions, 1 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 66d284cdd0..c252a57f82 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -22,6 +22,8 @@ Interface changes
--- mpv 0.29.0 ---
- drop deprecated --videotoolbox-format, --ff-aid, --ff-vid, --ff-sid,
--ad-spdif-dtshd, --softvol options
+ - fix --external-files: strictly never select any tracks from them, unless
+ explicitly selected (this may or may not be expected)
--- mpv 0.28.0 ---
- rename --hwdec=mediacodec option to mediacodec-copy, to reflect
conventions followed by other hardware video decoding APIs
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 1037e74e29..cc65ea98c3 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -5376,7 +5376,8 @@ Miscellaneous
Unlike ``--sub-files`` and ``--audio-files``, this includes all tracks, and
does not cause default stream selection over the "proper" file. This makes
- it slightly less intrusive.
+ it slightly less intrusive. (In mpv 0.28.0 and before, this was not quite
+ strictly enforced.)
This is a list option. See `List Options`_ for details.
diff --git a/player/core.h b/player/core.h
index cee1bf3bc2..041065e1f6 100644
--- a/player/core.h
+++ b/player/core.h
@@ -141,6 +141,7 @@ struct track {
// If this track is from an external file (e.g. subtitle file).
bool is_external;
bool no_default; // pretend it's not external for auto-selection
+ bool no_auto_select;
char *external_filename;
bool auto_loaded;
diff --git a/player/loadfile.c b/player/loadfile.c
index c54204db0b..daea9149e7 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -310,6 +310,7 @@ static int match_lang(char **langs, char *lang)
* Sort tracks based on the following criteria, and pick the first:
* 0a) track matches ff-index (always wins)
* 0b) track matches tid (almost always wins)
+ * 0c) track is not from --external-file
* 1) track is external (no_default cancels this)
* 1b) track was passed explicitly (is not an auto-loaded subtitle)
* 2) earlier match in lang list
@@ -371,6 +372,8 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
if (track->user_tid == tid)
return track;
+ if (track->no_auto_select)
+ continue;
if (!pick || compare_track(track, pick, langs, mpctx->opts))
pick = track;
@@ -624,6 +627,7 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
t->title = talloc_strdup(t, mp_basename(disp_filename));
t->external_filename = talloc_strdup(t, filename);
t->no_default = sh->type != filter;
+ t->no_auto_select = filter == STREAM_TYPE_COUNT;
if (!first && (filter == STREAM_TYPE_COUNT || sh->type == filter))
first = t;