Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load all external streams #5192

Merged
merged 3 commits into from Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions DOCS/man/options.rst
Expand Up @@ -1586,7 +1586,7 @@ Subtitles
``--sub-delay=<sec>``
Delays subtitles by ``<sec>`` seconds. Can be negative.

``--sub-files=<file-list>``
``--sub-files=<file-list>``, ``--sub-file=<filename>``
Add a subtitle file to the list of external subtitles.

If you use ``--sub-file`` only once, this subtitle file is displayed by
Expand All @@ -1598,7 +1598,11 @@ Subtitles
and ``--secondary-sid`` to select the second index. (The index is printed
on the terminal output after the ``--sid=`` in the list of streams.)

This is a list option. See `List Options`_ for details.
``--sub-files`` is a list option (see `List Options`_ for details), and
can take multiple file names separated by ``:`` (Unix) or ``;`` (Windows),
while ``--sub-file`` takes a single filename, but can be used multiple
times to add multiple files. Technically, ``--sub-file`` is a CLI/config
file only alias for ``--sub-files-append``.

``--secondary-sid=<ID|auto|no>``
Select a secondary subtitle stream. This is similar to ``--sid``. If a
Expand Down
37 changes: 24 additions & 13 deletions player/loadfile.c
Expand Up @@ -598,26 +598,37 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
goto err_out;
enable_demux_thread(mpctx, demuxer);

if (filter != STREAM_SUB && opts->rebase_start_time)
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;
Expand Down