summaryrefslogtreecommitdiffstats
path: root/player/external_files.c
Commit message (Collapse)AuthorAgeFilesLines
* command: restore lang after track reloadGuido Cella2024-01-201-0/+8
| | | | | | | | | | If a track's language was guessed from its filename, the commands that reload the track, like sub-reload, remove it. Fix this by calling guess_lang_from_filename() again. Note that backing up t->lang and restoring it if nt->lang is NULL would work incorrectly when lang is in the stream and it is removed before reloading.
* external_files: remove duplicate from cover art whitelistGuido Cella2023-10-041-1/+0
| | | | | I made a mistake in 0070a5820e here because there were 2 separate groups of "front" filenames.
* external_files: base cover-art-whitelist on cover-art-auto-extsGuido Cella2023-10-011-41/+10
| | | | | | | | | | Combine the cover art whitelist with the extensions in --cover-art-auto-exts instead of hardcoding them. This is shorter, checks for more extensions, saves us from updating the whitelist everytime we add a new image extension, and since the whitelist had gotten so big and the priority is calculated as MP_ARRAY_SIZE(cover_files) - n, files like cover.jpg were taking priority over cover art loaded by --cover-art-auto=exact.
* player: make all autoload extensions configurableDudemanguy2023-08-261-21/+18
| | | | | | | | | | | | | | | | | | | | | | | | --audio-file-auto, --cover-art-auto, and --sub-auto all work by using an internally hardcoded list that determine what file extensions get recognized. This is fine and people periodically update it, but we can actually expose this as a stringlist option instead. This way users can add or remove any file extension for any type. For the most part, this is pretty pretty easy and involves making sub_exts, etc. the defaults for the new options (--audio-file-auto-exts, --cover-art-auto-exts, and --sub-auto-exts). There's actually one slight complication however. The input code uses mp_might_be_subtitle_file which guesses if the file drag and dropped file is a subtitle. The input ctx has no access to mpctx so we have to be clever here. For this, the trick is to recognize that we can leverage the m_option_change_callback. We add a new flag, UPDATE_SUB_EXTS, which fires when the player starts up. Then in the callback, we can set the value of sub_exts in external_files to opts->sub_auto_exts. Whenever the option updates, the callback is fired again and sub_exts updates. That way mp_might_be_subtitle_file can just operate off of this global variable instead of trying to mess with the core mpv state directly. Fixes #12000.
* external_files: add sbv to the sub whitelistDudemanguy2023-08-101-2/+2
|
* external_files: alphabetize file extensionsDudemanguy2023-08-101-8/+8
| | | | Looks nicer.
* player: don't load unwanted files after 519e56fArthur Williams2023-06-071-9/+9
| | | | | | | | | | | | | | | 519e56f caused an attempt to get the language even if the file name didn't start with the movie title. However, detecting a language when fuzz >= 1 or the language is known, caused prio to be non-zero which caused the file to be included regardless of its name. This shouldn't be the behavior when sub-auto != all. Now all the prio updates that depend on lang will only happen if the file in question starts with the movie name. Since language was never detected before if this wasn't true, the behavior should be the same as before 519e56f when sub-auto != all. Closes: #11749
* player: always try to detect subtitle language from file nameArthur Williams2023-05-211-3/+2
| | | | | | | | | | | | | Previously, we'd only attempt to call guess_lang_from_filename if the external file name matched the video name ignoring the extensions. So if they didn't match, we'd just report the language as "unknown". And since the name will never match for urls, the language would always be treated as unknown. Now we'll always try to guess the language from the filename regardless of its similarity to the video file name. Closes #10348
* external_files: recognize jxl and avif files as cover artMartin Eesmaa2023-02-271-1/+17
|
* external_files: recognize webp files as cover artRon Shabi2022-12-291-0/+8
| | | | | | | | | | | | | mpv currently only recognizes jpg and png files named "AlbumArt", "Album", "cover", etc. which are in the same folder as the audio files as album/cover art and displays it when playing such audios. This feature adds support for webp files following the same naming scheme to be displayed as cover art for albums who have them. Webp variations are lower in priority compared to jpg or png files. Resolves: #11006
* external_files: set log level for potential files to traceNicolas F2022-12-211-1/+1
| | | | | | | | | | We ask users to freely share log files with us, which is usually okay, unless a user has some unrelated and potentially embarrassing files in their working directory. These would show up in the debug level message output that --log-file enables. Change the listing of potential external files to trace log level, to save the users and the developers the embarrassment.
* player: add tiff/tif (TIFF) to list of image extensionsAtticFinder655362022-06-071-1/+1
|
* player: add jxl (JPEG XL) to list of image extensionsAtticFinder655362022-06-071-1/+1
|
* player: add cover-art-whitelist optionGuido Cella2022-04-211-1/+1
| | | | | | | | This allows more fine grained control over which cover art to load. With --cover-art-auto=exact and --cover-art-whitelist=yes, you can now load cover art with the exact media filename and the whitelisted filenames, but not cover art that contains the media filename (--cover-art-auto=fuzzy).
* player: add thd (TrueHD) to whitelist of audio extensionschelobaka2022-01-191-1/+1
|
* player: eac3 to the whitelist of audio extensionsDudemanguy2021-07-301-1/+1
| | | | ffmpeg plays these just fine. Fixes #9065.
* player: change cover-art-auto behaviorGuido Cella2021-06-231-8/+4
| | | | | | | | | | | | | | This makes cover-art-auto behave more like sub-auto and audio-file-auto: - load cover art with a language, e.g. if playing foo.mp3, foo.en.jpg will be loaded with lang=en - load cover art containing the media filename with fuzzy and all, e.g. 'foo (large).jpg' - make all/2 load all images in the directory, and make fuzzy/1 the default These are all uncommon use cases, but synchronizing the behavior of the external file options simplifies the code.
* player: remove unnecessary checkGuido Cella2021-06-211-1/+1
| | | | | | | | | | | | Remove the check that the external filename is not the same as the currently playing one, which prevents mpv from loading images again as external cover art, but this isn't necessary because cover art is only added when playing standalone audio. I had only added this check because I would otherwise get a segfault only when compiling with gcc 10.2 with optimize and changing position within a playlist of multiple images (and this couldn't even be reproduced by Dudemanguy on the same gcc version), but this was caused by the uninitialized lang variable which is now fixed.
* player: fix segfaultGuido Cella2021-06-211-2/+1
| | | | | | | | | | | | | | | | | | Commit 029ff10 added a goto statement which skipped initializing the `lang' variable. This could crash depending on compiler optimizations and other factors: if the lang bstr pointer happened to end up NULL (which is apparently the case with most compilers) then it's validly empty, but if it pointed to a random and incorrect memory address then it crashed. The crash was observed when mpv was compiled using gcc 10.2 with optimizations enabled, and affected some third party Windows builds. This commit ensures the goto doesn't skip the initialization. Thanks to votemp for figuring this out. Fixes #8922.
* player: load cover art with the media filenameGuido Cella2021-05-271-11/+17
| | | | Closes #8666.
* player: fix external cover file prioritizationsfan52020-10-281-4/+8
| | | | | Array order was ignored entirely instead of being used as intended. Fixes: c07089a250
* player: reorder list of external cover files for optimal resultssfan52020-10-251-7/+9
|
* player: add automatic loading of external cover art fileswm42020-09-281-0/+37
| | | | | | | | | | | | | | | | | | | | | | | 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
* external_files: add .pgs subtitle extensionEva2020-07-211-1/+1
|
* player: make external subtitle auto-loading stricterwm42020-05-091-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | By default --sub-auto uses "exact". This was far from an "exact" match, because it added anything that started with the video filename (without extension), and seemed to end in something that looked like a language code. Make this stricter. "exact" still tolerate a language code, but the video's filename must come before it without any unknown extra characters. This may not load subtitles in some situations where it previously did, and where the user might think that the naming convention is such that it should be considered an exact match. The subtitle priority sorting seems a bit worthless. I suppose it may have some value in higher "fuzz" modes (like --sub-auto=fuzzy). Also remove the mysterious "prio += prio;" line. I probably shouldn't have checked, but it goes back to commit f16fa9d31 (2003), where someone wanted to "refine" the priority without changing the rest of the code or something. Mostly untested, so have fun. Fixes: #7702
* external_files: add .lrc subtitle extensionGuido Cella2019-09-021-1/+1
|
* player: get rid of mpv_global.optswm42018-05-241-14/+13
| | | | | | | | This was always a legacy thing. Remove it by applying an orgy of mp_get_config_group() calls, and sometimes m_config_cache_alloc() or mp_read_option_raw(). win32 changes untested.
* player: make track language matching case insensitivewm42017-12-231-1/+1
| | | | | | | | | There is no reason not to do this, and probably saves the user some trouble. Mostly untested. Closes #5272.
* player: match subtitles with language tags with --sub-auto=exactwm42017-11-271-18/+15
| | | | | | Apparently a relatively widespread convention, and almost as strict as the old "exact" semantics. (So it's not going to auto load radically unrelated files.)
* player: readd smi subtitle extensionwm42017-08-081-1/+1
| | | | | | | Fixes #4626. Previously removed because the original smi entry was added by someone who did not agree to LGPL relicensing. I'm not sure if the original change was copyrightable, but this commit for sure does not fall under that author's copyright.
* external_files: change license to LGPLwm42017-06-201-10/+10
| | | | | | | | | | | | | | | | | | | | | While we could easily ifdef-out this file for a LGPL core, it's still annoying, and also the only GPL file remaining in player/ that is not based on mplayer.c. This file originates from subreader.c. It's not clear whether the original author of it gave us permission to relicense to LGPL (he probably did, but without further clarification it's sort of ambiguous), but the subtitle file search code was written by other authors anyway (see 7eef93819f9d). One contribution (574eb892ea) is a bit of a corner case, as test_ext_list() now does a bstrcasecmp(). But I don't think the copyright remains here. (I asked the author anyway, just in case. But I didn't wait for the answer.) In some other cases, contributors who could not be reached added some subtitle extensions. I don't think those are copyrightable on their own, but I dropped them anyway just to be sure.
* external_files: parse ~ in --{sub,audio}-pathsrr-2017-05-311-3/+7
|
* external_files.c: add GPL headerwm42017-04-211-0/+17
| | | | | | It's been missing since mplayer2 times, not sure why. It originates from subreader.c. No analysis on whether it can be relicensed to LGPL was done yet.
* external_files: enable autoloading with URLsRicardo Constantino2017-04-011-3/+4
| | | | Closes #3264
* external_files: actually try to autoload from fallback pathsRicardo Constantino2017-04-011-2/+2
| | | | | | The 'sub' and 'audio' configuration subdirectories are supposed to be fallbacks for sub-paths and audio-file-paths respectively, but they weren't being scanned even if they existed.
* sub: remove .txt as text subtitle extensionwm42017-02-031-1/+1
| | | | | | | | | | | | | | | | If used with fuzzy matching, the player tends to pick up random text files, sometimes with interesting results. The most interesting interaction is when the user uses --log-file=something.txt, and mpv tries to open its own log file. It essentially "freezes" during probing, because every time it reads from it, it will write some more data, which in turn will cause more data to be read - until the 2MB max. probing size is slowly reached. This is not even an obscure corner case, but happened to multiple users. The .txt extension has been considered a subtitle extension ever since the code was added to MPlayer's subreader.c, but I'm not seeing many actual subtitle files with this extension, so just get rid of it.
* osx: consistent normalisation when searching for external filesAkemi2017-02-021-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | several unicode characters can be encoded in two different ways, either in a precomposed (NFC) or decomposed (NFD) representation. everywhere besides on macOS, specifically HFS+, precomposed strings are being used. furthermore on macOS we can get either precomposed or decomposed strings, for example when not HFS+ formatted volumes are used. that can be the case for network mounted devices (SMB, NFS) or optical/removable devices (UDF). this can lead to an inequality of actual equal strings, which can happen when comparing strings from different sources, like the command line or filesystem. this makes it mainly a problem on macOS systems. one case that can potential break is the sub-auto option. to prevent that we convert the search string as well as the string we search in to the same normalised representation, specifically we use the decomposed form which is used anywhere else. this could potentially be a problem on other platforms too, though the potential of occurring is very minor. for those platforms we don't convert anything and just fallback to the input. Fixes #4016
* player: add .scc subtitle extensionwm42017-01-311-1/+2
| | | | | | | | | Requested. Supposedly "scenarist closed captions". (The list of getting quite full. But it's probably still better than trying to probe the files by contents, because the external subtitle loader code will initially look at _all_ files in the same directory as the main file.)
* ta: remove old and redundant macrowm42016-05-171-1/+1
|
* player: add wv to list of external audio file extensionsMartin Herkt2016-03-261-0/+1
|
* player: fix previous commitwm42015-12-251-11/+17
| | | | | | | OK, this made the --sub-paths and --audio-file-paths synonyms, which is not what we wanted. Actually restrict the type of file loaded as well. Really fixes #2632.
* options: add --audio-file-pathswm42015-12-251-15/+22
| | | | | | | | Requested. It works like --sub-paths. This will also load audio files from a "audio" sub directory in the config file (because the same code as for subtitles is used, and it also had such a feature). Fixes #2632.
* external_files: deduplicate bstr functionsKevin Mitchell2015-11-091-20/+4
|
* player: add wav to list of external audio file extensionswm42015-10-041-1/+2
| | | | Fixes #2378.
* player: rename and move find_subfiles.cwm42015-09-201-0/+284
This was in sub/, because the code used to be specific to subtitles. It was extended to automatically load external audio files too, and moving the file and renaming it was long overdue.