diff options
-rw-r--r-- | DOCS/mplayer.1 | 5 | ||||
-rw-r--r-- | cfg-mplayer.h | 1 | ||||
-rw-r--r-- | mplayer.c | 1 | ||||
-rw-r--r-- | subreader.c | 53 |
4 files changed, 60 insertions, 0 deletions
diff --git a/DOCS/mplayer.1 b/DOCS/mplayer.1 index ffcba68937..dcd97ce12d 100644 --- a/DOCS/mplayer.1 +++ b/DOCS/mplayer.1 @@ -723,6 +723,11 @@ Convert the given subtitle (specified with the \-sub switch) to the time-based JACOsub subtitle format. Creates a dumpsub.js file in the current directory. .TP +.B \-dumpsami (MPLAYER only) +Convert the given subtitle (specified with the \-sub switch) to the time-based +SAMI subtitle format. +Creates a dumpsub.smi file in the current directory. +.TP .B \-dumpsub (MPLAYER only) (BETA CODE) Dumps the subtitle substream from VOB streams. See -dump*sub and -vobsubout* options too. diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 43c81b9338..7fd9c672d4 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -374,6 +374,7 @@ static config_t mplayer_opts[]={ {"dumpsrtsub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 6, NULL}, {"dumpmicrodvdsub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 7, NULL}, {"dumpjacosub", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 8, NULL}, + {"dumpsami", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 9, NULL}, #ifdef HAVE_LIRC {"lircconf", &lirc_configfile, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL}, @@ -1200,6 +1200,7 @@ if(sh_video) { if(subtitles && stream_dump_type==6) dump_srt(subtitles, sh_video->fps); if(subtitles && stream_dump_type==7) dump_microdvd(subtitles, sh_video->fps); if(subtitles && stream_dump_type==8) dump_jacosub(subtitles, sh_video->fps); + if(subtitles && stream_dump_type==9) dump_sami(subtitles, sh_video->fps); } #endif diff --git a/subreader.c b/subreader.c index 074403e10a..019e1fc4b8 100644 --- a/subreader.c +++ b/subreader.c @@ -1512,6 +1512,59 @@ void dump_jacosub(subtitle* subs, float fps) { mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.js\'.\n"); } +void dump_sami(subtitle* subs, float fps) { + int i,j; + FILE * fd; + subtitle * onesub; + unsigned long temp; + + if (!sub_uses_time && sub_fps == 0) + sub_fps = fps; + fd=fopen("dumpsub.smi","w"); + if(!fd) + { + perror("dump_jacosub: fopen"); + return; + } + fprintf(fd, "<SAMI>\n" + "<HEAD>\n" + " <STYLE TYPE=\"Text/css\">\n" + " <!--\n" + " P {margin-left: 29pt; margin-right: 29pt; font-size: 24pt; text-align: center; font-family: Tahoma; font-weight: bold; color: #FCDD03; background-color: #000000;}\n" + " .SUBTTL {Name: 'Subtitles'; Lang: en-US; SAMIType: CC;}\n" + " -->\n" + " </STYLE>\n" + "</HEAD>\n" + "<BODY>\n"); + for(i=0;i<sub_num;i++) + { + onesub=subs+i; //=&subs[i]; + + temp=onesub->start; + if (!sub_uses_time) + temp = temp * 100 / sub_fps; + temp -= sub_delay * 100; + fprintf(fd,"\t<SYNC Start=%lu>\n" + "\t <P>", temp * 10); + + for(j=0;j<onesub->lines;j++) + fprintf(fd,"%s%s",j ? "<br>" : "", onesub->text[j]); + + fprintf(fd,"\n"); + + temp=onesub->end; + if (!sub_uses_time) + temp = temp * 100 / sub_fps; + temp -= sub_delay * 100; + fprintf(fd,"\t<SYNC Start=%lu>\n" + "\t <P> \n", temp * 10); + } + fprintf(fd, "</BODY>\n" + "</SAMI>\n"); + fclose(fd); + mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Subtitles dumped in \'dumpsub.smi\'.\n"); +} + void sub_free( subtitle * subs ) { int i; |