From 86be4b35621bf9a4d2347c4add6dedc290940987 Mon Sep 17 00:00:00 2001 From: kmkaplan Date: Thu, 25 Jul 2002 18:05:08 +0000 Subject: Correct dump_srt millisecond output Add support for input from frame based subtitles to dump_srt. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6793 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 +- subreader.c | 14 +++++++++++--- subreader.h | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mplayer.c b/mplayer.c index 2c606e7ecd..9d38b58195 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1215,7 +1215,7 @@ if(sh_video) { } 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); + if(subtitles && stream_dump_type==6) dump_srt(subtitles, sh_video->fps); } #endif diff --git a/subreader.c b/subreader.c index 5fe0545dff..01d1f44fb5 100644 --- a/subreader.c +++ b/subreader.c @@ -915,13 +915,15 @@ void list_sub_file(subtitle* subs){ printf ("Read %i subtitles, %i errors.\n", sub_num, sub_errs); } -void dump_srt(subtitle* subs){ +void dump_srt(subtitle* subs, float fps){ int i,j; int h,m,s,ms; FILE * fd; subtitle * onesub; unsigned long temp; + if (!sub_uses_time && sub_fps == 0) + sub_fps = fps; fd=fopen("dumpsub.srt","w"); if(!fd) { @@ -934,17 +936,23 @@ unsigned long temp; fprintf(fd,"%d\n",i+1);//line number temp=onesub->start; + if (!sub_uses_time) + temp = temp * 100 / sub_fps; + temp -= sub_delay * 100; 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 + ms=temp*10; //ms=1*10 fprintf(fd,"%02d:%02d:%02d,%03d --> ",h,m,s,ms); temp=onesub->end; + if (!sub_uses_time) + temp = temp * 100 / sub_fps; + temp -= sub_delay * 100; h=temp/360000;temp%=360000; m=temp/6000; temp%=6000; s=temp/100; temp%=100; - ms=temp; + ms=temp*10; fprintf(fd,"%02d:%02d:%02d,%03d\n",h,m,s,ms); for(j=0;jlines;j++) diff --git a/subreader.h b/subreader.h index df9c6d4091..282d3b1870 100644 --- a/subreader.h +++ b/subreader.h @@ -38,7 +38,7 @@ typedef struct { 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_srt(subtitle* subs, float fps); void dump_mpsub(subtitle* subs, float fps); void sub_free( subtitle * subs ); void find_sub(subtitle* subtitles,int key); -- cgit v1.2.3