mirror of https://github.com/mpv-player/mpv
options: add --{video,audio,image}-exts
This commit is contained in:
parent
4f1e9e34c3
commit
44a3a3293f
|
@ -1,4 +1,4 @@
|
|||
add `--autocreate-playlist`
|
||||
add `--directory-video-exts`
|
||||
add `--directory-audio-exts`
|
||||
add `--directory-image-exts`
|
||||
add `--video-exts`
|
||||
add `--audio-exts`
|
||||
add `--image-exts`
|
||||
|
|
|
@ -2277,10 +2277,12 @@ Audio
|
|||
:all: Load all audio files in the current and ``--audio-file-paths``
|
||||
directories.
|
||||
|
||||
``--audio-file-auto-exts=ext1,ext2,...``
|
||||
Audio file extentions to try and match when using ``audio-file-auto``.
|
||||
``--audio-exts=ext1,ext2,...``
|
||||
Audio file extentions to try to match when using ``--audio-file-auto``,
|
||||
``--autocreate-playlist`` or ``--directory-filter-types``.
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
Use ``--help=audio-exts`` to see default extensions.
|
||||
|
||||
``--audio-file-paths=<path1:path2:...>``
|
||||
Equivalent to ``--sub-file-paths`` option, but for auto-loaded audio files.
|
||||
|
@ -4152,26 +4154,14 @@ Demuxer
|
|||
:no: Load a single file (default).
|
||||
:any: Create a playlist from the parent directory with any file type.
|
||||
:filter: Create a playlist from the parent directory with files matching
|
||||
extensions from any list ``directory-*-exts``.
|
||||
extensions from any list ``*-exts``.
|
||||
:same: Create a playlist from the parent directory with files matching the
|
||||
same category as the currently loaded file. One of the
|
||||
``directory-*-exts`` is selected based on the input file
|
||||
``*-exts`` is selected based on the input file
|
||||
and only files with matching extensions are added to the playlist.
|
||||
If the input file itself is not matched to any extension list,
|
||||
the playlist is not autogenerated.
|
||||
|
||||
``--directory-video-exts=<ext1,ext2,...>``
|
||||
Video file extension list that is used to match files when using
|
||||
``--autocreate-playlist=<exts|same>``.
|
||||
|
||||
``--directory-audio-exts=<ext1,ext2,...>``
|
||||
Audio file extension list that is used to match files when using
|
||||
``--autocreate-playlist=<exts|same>``.
|
||||
|
||||
``--directory-image-exts=<ext1,ext2,...>``
|
||||
Image file extension list that is used to match files when using
|
||||
``--autocreate-playlist=<exts|same>``.
|
||||
|
||||
Input
|
||||
-----
|
||||
|
||||
|
@ -7540,20 +7530,29 @@ Miscellaneous
|
|||
See ``--audio-display`` how to control display of cover art (this can be
|
||||
used to disable cover art that is part of the file).
|
||||
|
||||
``--cover-art-auto-exts=ext1,ext2,...``
|
||||
Cover art extentions to try and match when using ``cover-art-auto``.
|
||||
``--image-exts=ext1,ext2,...``
|
||||
Image file extentions to try to match when using ``--cover-art-auto``,
|
||||
``--autocreate-playlist`` or ``--directory-filter-types``.
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
Use ``--help=image-exts`` to see default extensions.
|
||||
|
||||
``--cover-art-whitelist=filename1,filename2,...``
|
||||
Filenames to load as cover art, sorted by descending priority. They are
|
||||
combined with the extensions in ``--cover-art-auto-exts``. This has no
|
||||
combined with the extensions in ``--image-exts``. This has no
|
||||
effect if ``cover-art-auto`` is ``no``.
|
||||
|
||||
Default: ``AlbumArt,Album,cover,front,AlbumArtSmall,Folder,.folder,thumb``
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
|
||||
``--video-exts=ext1,ext2,...``
|
||||
Video file extentions to try to match when using ``--autocreate-playlist`` or
|
||||
``--directory-filter-types``.
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
Use ``--help=video-exts`` to see default extensions.
|
||||
|
||||
``--autoload-files=<yes|no>``
|
||||
Automatically load/select external files (default: yes).
|
||||
|
||||
|
|
|
@ -54,9 +54,6 @@ enum autocreate_mode {
|
|||
struct demux_playlist_opts {
|
||||
int dir_mode;
|
||||
char **directory_filter;
|
||||
char **directory_vid_exts;
|
||||
char **directory_aud_exts;
|
||||
char **directory_img_exts;
|
||||
};
|
||||
|
||||
struct m_sub_options demux_playlist_conf = {
|
||||
|
@ -68,12 +65,6 @@ struct m_sub_options demux_playlist_conf = {
|
|||
{"ignore", DIR_IGNORE})},
|
||||
{"directory-filter-types",
|
||||
OPT_STRINGLIST(directory_filter)},
|
||||
{"directory-video-exts",
|
||||
OPT_STRINGLIST(directory_vid_exts)},
|
||||
{"directory-audio-exts",
|
||||
OPT_STRINGLIST(directory_aud_exts)},
|
||||
{"directory-image-exts",
|
||||
OPT_STRINGLIST(directory_img_exts)},
|
||||
{0}
|
||||
},
|
||||
.size = sizeof(struct demux_playlist_opts),
|
||||
|
@ -82,18 +73,6 @@ struct m_sub_options demux_playlist_conf = {
|
|||
.directory_filter = (char *[]){
|
||||
NULL
|
||||
},
|
||||
.directory_vid_exts = (char *[]){
|
||||
"3g2", "3gp", "avi", "flv", "m2ts", "m4v", "mj2", "mkv", "mov",
|
||||
"mp4", "mpeg", "mpg", "ogv", "rmvb", "webm", "wmv", "y4m", NULL
|
||||
},
|
||||
.directory_aud_exts = (char *[]){
|
||||
"aiff", "ape", "au", "flac", "m4a", "mka", "mp3", "oga", "ogg",
|
||||
"ogm", "opus", "wav", "wma", NULL
|
||||
},
|
||||
.directory_img_exts = (char *[]){
|
||||
"avif", "bmp", "gif", "j2k", "jp2", "jpeg", "jpg", "jxl", "png",
|
||||
"svg", "tga", "tif", "tiff", "webp", NULL
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -126,6 +105,7 @@ struct pl_parser {
|
|||
char *format;
|
||||
char *codepage;
|
||||
struct demux_playlist_opts *opts;
|
||||
struct MPOpts *mp_opts;
|
||||
};
|
||||
|
||||
|
||||
|
@ -447,11 +427,11 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate)
|
|||
return true;
|
||||
|
||||
bstr ext = bstr_get_ext(bstr0(path));
|
||||
if (autocreate & AUTO_VIDEO && has_str(ext, p->opts->directory_vid_exts))
|
||||
if (autocreate & AUTO_VIDEO && has_str(ext, p->mp_opts->video_exts))
|
||||
return true;
|
||||
if (autocreate & AUTO_AUDIO && has_str(ext, p->opts->directory_aud_exts))
|
||||
if (autocreate & AUTO_AUDIO && has_str(ext, p->mp_opts->audio_exts))
|
||||
return true;
|
||||
if (autocreate & AUTO_IMAGE && has_str(ext, p->opts->directory_img_exts))
|
||||
if (autocreate & AUTO_IMAGE && has_str(ext, p->mp_opts->image_exts))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -541,11 +521,11 @@ static int parse_dir(struct pl_parser *p)
|
|||
autocreate = AUTO_VIDEO | AUTO_AUDIO | AUTO_IMAGE;
|
||||
break;
|
||||
case 3: // same
|
||||
if (has_str(ext, p->opts->directory_vid_exts)) {
|
||||
if (has_str(ext, p->mp_opts->video_exts)) {
|
||||
autocreate = AUTO_VIDEO;
|
||||
} else if (has_str(ext, p->opts->directory_aud_exts)) {
|
||||
} else if (has_str(ext, p->mp_opts->audio_exts)) {
|
||||
autocreate = AUTO_AUDIO;
|
||||
} else if (has_str(ext, p->opts->directory_img_exts)) {
|
||||
} else if (has_str(ext, p->mp_opts->image_exts)) {
|
||||
autocreate = AUTO_IMAGE;
|
||||
}
|
||||
break;
|
||||
|
@ -561,7 +541,7 @@ static int parse_dir(struct pl_parser *p)
|
|||
}
|
||||
} else {
|
||||
autocreate = AUTO_NONE;
|
||||
if (!p->opts->directory_filter[0])
|
||||
if (!p->opts->directory_filter || !p->opts->directory_filter[0])
|
||||
autocreate = AUTO_ANY;
|
||||
if (has_str(bstr0("video"), p->opts->directory_filter))
|
||||
autocreate |= AUTO_VIDEO;
|
||||
|
@ -675,6 +655,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
|
|||
p->check_level = check;
|
||||
p->probing = true;
|
||||
p->autocreate_playlist = demuxer->params->allow_playlist_create ? opts->autocreate_playlist : 0;
|
||||
p->mp_opts = mp_get_config_group(demuxer, demuxer->global, &mp_opt_root);
|
||||
p->opts = mp_get_config_group(demuxer, demuxer->global, &demux_playlist_conf);
|
||||
|
||||
const struct pl_format *fmts = playlist_formats;
|
||||
|
|
|
@ -720,11 +720,14 @@ static const m_option_t mp_opts[] = {
|
|||
{"sub-auto-exts", OPT_STRINGLIST(sub_auto_exts), .flags = UPDATE_SUB_EXTS},
|
||||
{"audio-file-auto", OPT_CHOICE(audiofile_auto,
|
||||
{"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
|
||||
{"audio-file-auto-exts", OPT_STRINGLIST(audiofile_auto_exts)},
|
||||
{"audio-exts", OPT_STRINGLIST(audio_exts)},
|
||||
{"audio-file-auto-exts", OPT_ALIAS("audio-exts")},
|
||||
{"cover-art-auto", OPT_CHOICE(coverart_auto,
|
||||
{"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
|
||||
{"cover-art-auto-exts", OPT_STRINGLIST(coverart_auto_exts)},
|
||||
{"image-exts", OPT_STRINGLIST(image_exts)},
|
||||
{"cover-art-auto-exts", OPT_ALIAS("image-exts")},
|
||||
{"cover-art-whitelist", OPT_STRINGLIST(coverart_whitelist)},
|
||||
{"video-exts", OPT_STRINGLIST(video_exts)},
|
||||
|
||||
{"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)},
|
||||
{"", OPT_SUBSTRUCT(subs_shared, mp_subtitle_shared_sub_opts)},
|
||||
|
@ -1044,36 +1047,17 @@ static const struct MPOpts mp_default_opts = {
|
|||
.screenshot_template = "mpv-shot%n",
|
||||
.play_dir = 1,
|
||||
.media_controls = 1,
|
||||
|
||||
.audiofile_auto_exts = (char *[]){
|
||||
"aac",
|
||||
"ac3",
|
||||
"dts",
|
||||
"eac3",
|
||||
"flac",
|
||||
"m4a",
|
||||
"mka",
|
||||
"mp3",
|
||||
"ogg",
|
||||
"opus",
|
||||
"thd",
|
||||
"wav",
|
||||
"wv",
|
||||
NULL
|
||||
.video_exts = (char *[]){
|
||||
"3g2", "3gp", "avi", "flv", "m2ts", "m4v", "mj2", "mkv", "mov", "mp4",
|
||||
"mpeg", "mpg", "ogv", "rmvb", "ts", "webm", "wmv", "y4m", NULL
|
||||
},
|
||||
|
||||
.coverart_auto_exts = (char *[]){
|
||||
"avif",
|
||||
"bmp",
|
||||
"gif",
|
||||
"jpeg",
|
||||
"jpg",
|
||||
"jxl",
|
||||
"png",
|
||||
"tif",
|
||||
"tiff",
|
||||
"webp",
|
||||
NULL
|
||||
.audio_exts = (char *[]){
|
||||
"aac", "ac3", "aiff", "ape", "au", "dts", "eac3", "flac", "m4a", "mka",
|
||||
"mp3", "oga", "ogg", "ogm", "opus", "thd", "wav", "wav", "wma", "wv", NULL
|
||||
},
|
||||
.image_exts = (char *[]){
|
||||
"avif", "bmp", "gif", "j2k", "jp2", "jpeg", "jpg", "jxl", "png",
|
||||
"svg", "tga", "tif", "tiff", "webp", NULL
|
||||
},
|
||||
|
||||
.sub_auto_exts = (char *[]){
|
||||
|
|
|
@ -338,10 +338,11 @@ typedef struct MPOpts {
|
|||
int sub_auto;
|
||||
char **sub_auto_exts;
|
||||
int audiofile_auto;
|
||||
char **audiofile_auto_exts;
|
||||
char **audio_exts;
|
||||
int coverart_auto;
|
||||
char **coverart_auto_exts;
|
||||
char **image_exts;
|
||||
char **coverart_whitelist;
|
||||
char **video_exts;
|
||||
bool osd_bar_visible;
|
||||
|
||||
int w32_priority;
|
||||
|
|
|
@ -49,9 +49,9 @@ static int test_ext(MPOpts *opts, bstr ext)
|
|||
{
|
||||
if (test_ext_list(ext, opts->sub_auto_exts))
|
||||
return STREAM_SUB;
|
||||
if (test_ext_list(ext, opts->audiofile_auto_exts))
|
||||
if (test_ext_list(ext, opts->audio_exts))
|
||||
return STREAM_AUDIO;
|
||||
if (test_ext_list(ext, opts->coverart_auto_exts))
|
||||
if (test_ext_list(ext, opts->image_exts))
|
||||
return STREAM_VIDEO;
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue