mirror of
https://github.com/mpv-player/mpv
synced 2025-03-22 11:18:32 +00:00
find_subfiles: try to determine if a .sub file is text or vobsub
A file with the ambiguous extension .sub could be either VOBsub or MicroDVD. If there's a corresponding .idx file it's certainly VOBsub, so don't add it to the list of potential text subtitles. This will avoid the annoying warning "SUB: Could not determine file format".
This commit is contained in:
parent
1c6995d76c
commit
1a152eadaf
@ -153,6 +153,20 @@ static void append_dir_subtitles(struct subfn **slist, int *nsub,
|
||||
strcpy_get_ext(tmp_fname_ext, de->d_name);
|
||||
strcpy_trim(tmp_fname_trim, tmp_fname_noext);
|
||||
|
||||
// If it's a .sub, check if there is a .idx with the same name. If
|
||||
// there is one, it's certainly a vobsub so we skip it.
|
||||
if (strcasecmp(tmp_fname_ext, "sub") == 0) {
|
||||
struct bstr idxname = BSTR(talloc_strdup(NULL, de->d_name));
|
||||
strcpy(idxname.start + idxname.len - sizeof("idx") + 1, "idx");
|
||||
char *idx = mp_path_join(idxname.start, path, idxname);
|
||||
f = fopen(idx, "rt");
|
||||
talloc_free(idxname.start);
|
||||
if (f) {
|
||||
fclose(f);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// does it end with a subtitle extension?
|
||||
found = 0;
|
||||
#ifdef CONFIG_ICONV
|
||||
|
Loading…
Reference in New Issue
Block a user