aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2017-12-07 10:32:29 +0100
committerGravatar Kevin Mitchell <kevmitch@gmail.com>2017-12-07 23:48:16 -0800
commit80d43ee4e692f13358f134c906ba2c5439ecde5f (patch)
treeea9a587cb5893480f50b2ffde1ebe29ffae87832
parent520fc7403621156676b1ca183aed4911bf6c47b5 (diff)
player: when loading external file, always add all track types
Until now, using --sub-file would add only subtitle tracks from the given file. (E.g. if you passed a video file, only the subtitle tracks from it were added, not the video or audio tracks.) This is slightly messy (because streams are hidden), and users don't even want it, as shown by #5132. Change it to always add all streams. But if there's no stream of the wanted type, we still report an error and do not add any streams. It's also made sure none of the other track types are autoselected. Also adjust the error messages on load failure slightly. Fixes #5132.
-rw-r--r--player/loadfile.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 674902e9be..ff401cd590 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -601,23 +601,34 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
if (opts->rebase_start_time)
demux_set_ts_offset(demuxer, -demuxer->start_time);
- struct track *first = NULL;
+ bool has_any = false;
for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
struct sh_stream *sh = demux_get_stream(demuxer, n);
- if (filter == STREAM_TYPE_COUNT || sh->type == filter) {
- struct track *t = add_stream_track(mpctx, demuxer, sh);
- 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 (sh->type == filter || filter == STREAM_TYPE_COUNT) {
+ has_any = true;
+ break;
}
}
- if (!first) {
+
+ if (!has_any) {
free_demuxer_and_stream(demuxer);
- MP_WARN(mpctx, "No streams added from file %s.\n", disp_filename);
- goto err_out;
+ char *tname = mp_tprintf(20, "%s ", stream_type_name(filter));
+ if (filter == STREAM_TYPE_COUNT)
+ tname = "";
+ MP_ERR(mpctx, "No %sstreams in file %s.\n", tname, disp_filename);
+ return false;
+ }
+
+ struct track *first = NULL;
+ for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
+ struct sh_stream *sh = demux_get_stream(demuxer, n);
+ struct track *t = add_stream_track(mpctx, demuxer, sh);
+ t->is_external = true;
+ t->title = talloc_strdup(t, mp_basename(disp_filename));
+ t->external_filename = talloc_strdup(t, filename);
+ t->no_default = sh->type != filter;
+ if (!first && (filter == STREAM_TYPE_COUNT || sh->type == filter))
+ first = t;
}
return first;