player: add automatic loading of external cover art files

Picks up files like "cover.jpg". It's made part of normal external file
loading, so I'm adding 3 new options that are direct equivalents for the
options that control loading of external subtitle and audio files. Even
though I bet nobody wants them and they just increase confusion... I
guess the world is actually hell, so this outcome should be fine.

It prefers non-specific external files like "cover.jpg" over embedded
cover art. Not sure if that's wanted or unwanted.

There's some pain over explicitly marking such files as external
pictures. This is basically an optimization: in most cases, a heuristic
would treat an image file loaded with --external-file the same (it's a
heuristic because ffmpeg can't tell us whether something is an image or
a video). However, even with this heuristic, it would decode the cover
art picture again on each seek, which would essentially slow down
seeking in audio files. This bothered me greatly, which is why I'm
adding these additional options at all, and bothered with the previous
commit.

Fixes: #3056
This commit is contained in:
wm4
2020-09-28 00:12:52 +02:00
parent 102a4a8b06
commit 55d7f9ded1
6 changed files with 95 additions and 8 deletions

View File

@@ -512,8 +512,6 @@ static const m_option_t mp_opts[] = {
#endif
// demuxer.c - select audio/sub file/demuxer
{"audio-files", OPT_PATHLIST(audio_files), .flags = M_OPT_FILE},
{"audio-file", OPT_CLI_ALIAS("audio-files-append")},
{"demuxer", OPT_STRING(demuxer_name)},
{"audio-demuxer", OPT_STRING(audio_demuxer_name)},
{"sub-demuxer", OPT_STRING(sub_demuxer_name)},
@@ -573,15 +571,24 @@ static const m_option_t mp_opts[] = {
{"sub-files", OPT_PATHLIST(sub_name), .flags = M_OPT_FILE},
{"sub-file", OPT_CLI_ALIAS("sub-files-append")},
{"audio-files", OPT_PATHLIST(audio_files), .flags = M_OPT_FILE},
{"audio-file", OPT_CLI_ALIAS("audio-files-append")},
{"cover-art-files", OPT_PATHLIST(coverart_files), .flags = M_OPT_FILE},
{"cover-art-file", OPT_CLI_ALIAS("covert-art-files-append")},
{"sub-file-paths", OPT_PATHLIST(sub_paths), .flags = M_OPT_FILE},
{"audio-file-paths", OPT_PATHLIST(audiofile_paths), .flags = M_OPT_FILE},
{"external-files", OPT_PATHLIST(external_files), .flags = M_OPT_FILE},
{"external-file", OPT_CLI_ALIAS("external-files-append")},
{"autoload-files", OPT_FLAG(autoload_files)},
{"sub-auto", OPT_CHOICE(sub_auto,
{"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
{"audio-file-auto", OPT_CHOICE(audiofile_auto,
{"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
{"cover-art-auto", OPT_CHOICE(coverart_auto,
{"no", -1}, {"fuzzy", 1})},
{"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)},
{"", OPT_SUBSTRUCT(subs_filt, mp_sub_filter_opts)},
@@ -1002,6 +1009,7 @@ static const struct MPOpts mp_default_opts = {
.pitch_correction = 1,
.sub_auto = 0,
.audiofile_auto = -1,
.coverart_auto = 1,
.osd_bar_visible = 1,
.screenshot_template = "mpv-shot%n",
.play_dir = 1,

View File

@@ -291,10 +291,12 @@ typedef struct MPOpts {
char **sub_name;
char **sub_paths;
char **audiofile_paths;
char **coverart_files;
char **external_files;
int autoload_files;
int sub_auto;
int audiofile_auto;
int coverart_auto;
int osd_bar_visible;
int w32_priority;