changeset 6208:86162cb34bc9

added dump subtitles to .srt
author iive
date Mon, 27 May 2002 17:20:55 +0000
parents 1c5bde0ef5d1
children e46b3bf16df5
files subreader.c subreader.h
diffstat 2 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/subreader.c	Mon May 27 17:18:06 2002 +0000
+++ b/subreader.c	Mon May 27 17:20:55 2002 +0000
@@ -886,6 +886,46 @@
     printf ("Read %i subtitles, %i errors.\n", sub_num, sub_errs);
 
 }
+void dump_srt(subtitle* subs){
+int i,j;
+int h,m,s,ms;
+FILE * fd;
+subtitle * onesub;
+unsigned long temp;
+
+    fd=fopen("dumpsub.srt","w");
+    if(!fd)
+    { 
+	perror("dump_srt: fopen");
+	return;
+    }
+    for(i=0;i<sub_num;i++)
+    {
+        onesub=subs+i;    //=&subs[i];
+	fprintf(fd,"%d\n",i+1);//line number
+
+	temp=onesub->start;
+	h=temp/360000;temp%=360000;	//h =1*100*60*60
+	m=temp/6000;  temp%=6000;	//m =1*100*60
+	s=temp/100;   temp%=100;	//s =1*100
+	ms=temp;       			//ms=1
+	fprintf(fd,"%02d:%02d:%02d,%03d --> ",h,m,s,ms);
+
+	temp=onesub->end;
+	h=temp/360000;temp%=360000;
+	m=temp/6000;  temp%=6000;
+	s=temp/100;   temp%=100;
+	ms=temp;       
+	fprintf(fd,"%02d:%02d:%02d,%03d\n",h,m,s,ms);
+	
+	for(j=0;j<onesub->lines;j++)
+	    fprintf(fd,"%s\n",onesub->text[j]);
+
+	fprintf(fd,"\n");
+    }
+    fclose(fd);
+    printf ("SUB: Subtitles dumped in \'dumpsub.srt\'.\n");
+}
 
 void dump_mpsub(subtitle* subs, float fps){
 	int i,j;
--- a/subreader.h	Mon May 27 17:18:06 2002 +0000
+++ b/subreader.h	Mon May 27 17:20:55 2002 +0000
@@ -38,6 +38,7 @@
 subtitle* sub_read_file (char *filename, float pts);
 char * sub_filename(char *path, char * fname);
 void list_sub_file(subtitle* subs);
+void dump_srt(subtitle* subs);
 void dump_mpsub(subtitle* subs, float fps);
 void sub_free( subtitle * subs );
 void find_sub(subtitle* subtitles,int key);