[Mplayer-cvslog] CVS: main subreader.c,1.60,1.61 subreader.h,1.14,1.15
Ivan Kalvachev
iive at mplayerhq.hu
Mon May 27 19:20:58 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv3906
Modified Files:
subreader.c subreader.h
Log Message:
added dump subtitles to .srt
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- subreader.c 23 May 2002 15:27:49 -0000 1.60
+++ subreader.c 27 May 2002 17:20:55 -0000 1.61
@@ -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;
Index: subreader.h
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- subreader.h 13 May 2002 20:41:20 -0000 1.14
+++ subreader.h 27 May 2002 17:20:55 -0000 1.15
@@ -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);
More information about the MPlayer-cvslog
mailing list