diff options
author | Clément Bœsch <ubitux@gmail.com> | 2011-03-03 11:39:18 +0100 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-04-20 04:22:53 +0300 |
commit | 1a152eadaf1e2d8beac37d13ba22958b0946db8b (patch) | |
tree | 89b664721db2f57657883fae4a174b62ae01ab1f /sub/find_subfiles.c | |
parent | 1c6995d76cfb26a1a87dd4d23a6260e9cf7ecb62 (diff) | |
download | mpv-1a152eadaf1e2d8beac37d13ba22958b0946db8b.tar.bz2 mpv-1a152eadaf1e2d8beac37d13ba22958b0946db8b.tar.xz |
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".
Diffstat (limited to 'sub/find_subfiles.c')
-rw-r--r-- | sub/find_subfiles.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 85ea47b0c2..31413724a8 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -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 |