[MPlayer-dev-eng] [PATCH] Avoid raising error when trying to load a vobsub.
Clément Bœsch
ubitux at gmail.com
Tue Feb 1 20:40:05 CET 2011
On Sat, Jan 22, 2011 at 12:58:02PM +0100, Clément Bœsch wrote:
> On Sat, Jan 22, 2011 at 12:06:21PM +0100, Reimar Döffinger wrote:
> > On Sat, Jan 22, 2011 at 11:33:41AM +0100, Clément Bœsch wrote:
> > > On Sat, Jan 22, 2011 at 11:15:06AM +0100, Reimar Döffinger wrote:
> > > > On Fri, Jan 21, 2011 at 10:54:27PM +0100, Clément Bœsch wrote:
> > > > > On Thu, Jan 13, 2011 at 12:38:06AM +0100, Clément Bœsch wrote:
> > > > > > [...]
> > > > > > From 3ac94829563a5caba4e14457ea5a95cf03948736 Mon Sep 17 00:00:00 2001
> > > > > > From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
> > > > > > Date: Thu, 13 Jan 2011 00:34:38 +0100
> > > > > > Subject: [PATCH] Avoid raising error when trying to load a vobsub.
> > > > > >
> > > > >
> > > > > Ping (j-3)
> > > >
> > > > I haven't checked how vobsubs even appear there, as I understand it normal
> > > > subs are loaded with -sub and vobsubs with -vobsub so there's no reason
> > > > for that code to be executed?
> > >
> > > MicroDVD and vobsub share the same extension .sub, so when tracking
> > > text subtitles, binary .sub also get opened.
> >
> > Ah, ok. In that case maybe add a comment that it's only to suppress a warning
> > for the case where we got a vobsub sub into the text-sub autoload list.
>
> Ok.
>
> > What happens though if someone does -sub somevobsub, is it ignored without
> > warning, too?
> >
>
> Yes, and indeed this is problematic… I'm not sure how to handle this.
> Checking for the existence of a corresponding .idx in append_dir_subtitles
> may not that bad then. Any better idea?
>
Here is a new try. Feel free to comment. I'll apply this version at the
end of the week if no objection.
I can also add a check for MPEG just like there was in the previous patch
(just need to read 4 bytes, the file is already opened), but it seems
overkill, and I guess it would slow down things.
Note you can now force the sub with -sub.
--
Clément B.
-------------- next part --------------
From 7675a9be1dd80457cb3ead3604d9fbf6f4715518 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Tue, 25 Jan 2011 08:24:15 +0100
Subject: [PATCH 5/5] Do not add .sub to text subtitles when they look like vobsub.
This will avoid the annoying message "SUB: Could not determine file
format" because of MicroDVD and VOBsub sharing the same extension.
---
sub/subreader.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/sub/subreader.c b/sub/subreader.c
index 998c9f1..a95c12c 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -1957,6 +1957,22 @@ static void append_dir_subtitles(struct sub_list *slist, const char *path,
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) {
+ char *idx, *idxname = strdup(de->d_name);
+
+ strcpy(idxname + strlen(de->d_name) - sizeof("idx") + 1, "idx");
+ idx = mp_dir_join(path, idxname);
+ free(idxname);
+ f = fopen(idx, "rt");
+ free(idx);
+ if (f) {
+ fclose(f);
+ continue;
+ }
+ }
+
// does it end with a subtitle extension?
found = 0;
#ifdef CONFIG_ICONV
--
1.7.3.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110201/5b253830/attachment-0001.pgp>
More information about the MPlayer-dev-eng
mailing list