1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-18 13:16:43 +00:00

player: add --external-file option

Mostly intended for use with --lavfi-complex.
This commit is contained in:
wm4 2016-02-08 21:18:35 +01:00
parent 09d61032ca
commit 3d9e1ad363
4 changed files with 19 additions and 14 deletions

View File

@ -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

View File

@ -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),

View File

@ -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;

View File

@ -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);