changeset 7460:fdf31bb0450f

New option for mplayer: -dumpmicrodvdsub
author kmkaplan
date Sat, 21 Sep 2002 17:23:46 +0000
parents 9975a432cf47
children 855ca896de24
files cfg-mplayer.h mplayer.c subreader.c subreader.h
diffstat 4 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Sat Sep 21 16:04:14 2002 +0000
+++ b/cfg-mplayer.h	Sat Sep 21 17:23:46 2002 +0000
@@ -328,6 +328,7 @@
 	{"dumpmpsub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 4, NULL},
 	{"dumpstream", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 5, NULL},
 	{"dumpsrtsub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 6, NULL},
+	{"dumpmicrodvdsub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 7, NULL},
 
 #ifdef HAVE_LIRC
 	{"lircconf", &lirc_configfile, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL}, 
--- a/mplayer.c	Sat Sep 21 16:04:14 2002 +0000
+++ b/mplayer.c	Sat Sep 21 17:23:46 2002 +0000
@@ -1204,6 +1204,7 @@
   if(subtitles && stream_dump_type==3) list_sub_file(subtitles);
   if(subtitles && stream_dump_type==4) dump_mpsub(subtitles, sh_video->fps);
   if(subtitles && stream_dump_type==6) dump_srt(subtitles, sh_video->fps);
+  if(subtitles && stream_dump_type==7) dump_microdvd(subtitles, sh_video->fps);
 }
 #endif
 
--- a/subreader.c	Sat Sep 21 16:04:14 2002 +0000
+++ b/subreader.c	Sat Sep 21 17:23:46 2002 +0000
@@ -1007,6 +1007,40 @@
 	mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dump.mpsub\'.\n");
 }
 
+void dump_microdvd(subtitle* subs, float fps) {
+    int i, delay;
+    FILE *fd;
+    if (sub_fps == 0)
+	sub_fps = fps;
+    fd = fopen("dumpsub.txt", "w");
+    if (!fd) {
+	perror("dumpsub.txt: fopen");
+	return;
+    }
+    delay = sub_delay * sub_fps;
+    for (i = 0; i < sub_num; ++i) {
+	int j, start, end;
+	start = subs[i].start;
+	end = subs[i].end;
+	if (sub_uses_time) {
+	    start = start * sub_fps / 100 ;
+	    end = end * sub_fps / 100;
+	}
+	else {
+	    start = start * sub_fps / fps;
+	    end = end * sub_fps / fps;
+	}
+	start -= delay;
+	end -= delay;
+	fprintf(fd, "{%d}{%d}", start, end);
+	for (j = 0; j < subs[i].lines; ++j) 
+	    fprintf(fd, "%s%s", j ? "|" : "", subs[i].text[j]);
+	fprintf(fd, "\n");
+    }
+    fclose(fd);
+    mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.txt\'.\n");
+}
+
 void sub_free( subtitle * subs )
 {
  int i;
--- a/subreader.h	Sat Sep 21 16:04:14 2002 +0000
+++ b/subreader.h	Sat Sep 21 17:23:46 2002 +0000
@@ -40,6 +40,7 @@
 void list_sub_file(subtitle* subs);
 void dump_srt(subtitle* subs, float fps);
 void dump_mpsub(subtitle* subs, float fps);
+void dump_microdvd(subtitle* subs, float fps);
 void sub_free( subtitle * subs );
 void find_sub(subtitle* subtitles,int key);
 #endif