u8sand / Baka-MPlayer

The libmpv based media player
https://u8sand.github.io/Baka-MPlayer/
GNU General Public License v2.0
431 stars 93 forks source link

Add automatic subtitle detection #267

Closed Smile4ever closed 6 years ago

Smile4ever commented 6 years ago

At least ".srt", ".*.srt" (for example, a file ending with .en.srt) in the current directory and the subdirectory "subs".

First asked in #186

u8sand commented 6 years ago

Both .srt and .sub are considered in general application flow. Relevant filetypes here: https://github.com/u8sand/Baka-MPlayer/blob/master/src/mpvtypes.h#L16

Frankly I was under the impression mpv automatically detected these types of files itself, hence the code we have here to ask about deleting sub files with the same name but different extension: https://github.com/u8sand/Baka-MPlayer/blob/master/src/widgets/playlistwidget.cpp#L281-L317

In fact the related issue in mpv is: https://github.com/mpv-player/mpv/issues/4008 which suggests that adding sub-auto=fuzzy to config would help. You can add this to baka-config yourself but I'll add it as one of the default parameters. Please try it for me to confirm that it works.

Smile4ever commented 6 years ago

Before this change, exact matching of SRT files worked.

After the change

So it's an improvement, but it's not perfect yet.

u8sand commented 6 years ago

Mpv has a setting for this, I don't plan to add it as a default setting because I don't think people usually anticipate this functionality.


       --sub-file-paths=<path-list>
              Specify extra directories to search for subtitles matching the video.  Multiple directories can be separated by ":" (";" on  Windows).
              Paths  can be relative or absolute. Relative paths are interpreted relative to video file directory.  If the file is a URL, only abso‐
              lute paths and sub configuration subdirectory will be scanned.

                 Example

                        Assuming that /path/to/video/video.avi is played and --sub-file-paths=sub:subtitles is specified, mpv searches for  subtitle
                        files in these directories:

                 · /path/to/video/

                 · /path/to/video/sub/

                 · /path/to/video/subtitles/

                 · the sub configuration subdirectory (usually ~/.config/mpv/sub/)

              This is a list option. See List Options for details.

To add it, add it to the mpv options in bakamplayer.ini (https://github.com/u8sand/Baka-MPlayer/blob/master/DOCS/settings.md)