Mercurial > mplayer.hg
changeset 14684:a4767edef10d
command to log current subtitle to file
author | henry |
---|---|
date | Sat, 12 Feb 2005 14:45:54 +0000 |
parents | a99bdb15d2aa |
children | 4b02f759f529 |
files | DOCS/tech/slave.txt input/input.c input/input.h mplayer.c |
diffstat | 4 files changed, 54 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/tech/slave.txt Sat Feb 12 14:38:50 2005 +0000 +++ b/DOCS/tech/slave.txt Sat Feb 12 14:45:54 2005 +0000 @@ -101,6 +101,12 @@ -sub options on the command line, VOBsubs, DVD subtitles, and Ogg text streams. +sub_log + Logs the current or last displayed subtitle together with filename + and time information to ~/.mplayer/subtitle_log. Intended purpose + is to allow convenient marking of bogus subtitles which need to be + fixed while watching the movie. + vobsub_lang This is a stub linked to sub_select for backwards compatibility.
--- a/input/input.c Sat Feb 12 14:38:50 2005 +0000 +++ b/input/input.c Sat Feb 12 14:45:54 2005 +0000 @@ -79,6 +79,7 @@ { MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } }, { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { {-1,{0}} } }, // for compatibility { MP_CMD_SUB_SELECT, "sub_select", 0, { {-1,{0}} } }, + { MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, { MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } }, { MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } }, #ifdef USE_TV
--- a/input/input.h Sat Feb 12 14:38:50 2005 +0000 +++ b/input/input.h Sat Feb 12 14:45:54 2005 +0000 @@ -62,6 +62,7 @@ #define MP_CMD_SPEED_MULT 58 #define MP_CMD_SPEED_SET 59 #define MP_CMD_RUN 60 +#define MP_CMD_SUB_LOG 61 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001
--- a/mplayer.c Sat Feb 12 14:38:50 2005 +0000 +++ b/mplayer.c Sat Feb 12 14:45:54 2005 +0000 @@ -754,6 +754,7 @@ #ifdef USE_SUB sub_data* subdata = NULL; +static subtitle* vo_sub_last = NULL; void add_subtitles(char *filename, float fps, int silent) { @@ -962,6 +963,43 @@ return result; } +#ifdef USE_SUB +/** + * \brief Log the currently displayed subtitle to a file + * + * Logs the current or last displayed subtitle together with filename + * and time information to ~/.mplayer/subtitle_log + * + * Intended purpose is to allow convenient marking of bogus subtitles + * which need to be fixed while watching the movie. + */ + +static void log_sub(){ + char *fname; + FILE *f; + int i; + + if (subdata == NULL || vo_sub_last == NULL) return; + fname = get_path("subtitle_log"); + f = fopen(fname, "a"); + if (!f) return; + fprintf(f, "----------------------------------------------------------\n"); + if (subdata->sub_uses_time) { + fprintf(f, "N: %s S: %02d:%02d:%02d.%02d E: %02d:%02d:%02d.%02d\n", filename, + vo_sub_last->start/360000, (vo_sub_last->start/6000)%60, + (vo_sub_last->start/100)%60, vo_sub_last->start%100, + vo_sub_last->end/360000, (vo_sub_last->end/6000)%60, + (vo_sub_last->end/100)%60, vo_sub_last->end%100); + } else { + fprintf(f, "N: %s S: %d E: %d\n", filename, vo_sub_last->start, vo_sub_last->end); + } + for (i = 0; i < vo_sub_last->lines; i++) { + fprintf(f, "%s\n", vo_sub_last->text[i]); + } + fclose(f); +} +#endif + int main(int argc,char* argv[]){ @@ -2861,6 +2899,11 @@ } #endif } break; + case MP_CMD_SUB_LOG : { +#ifdef USE_SUB + log_sub(); +#endif + } break; case MP_CMD_OSD : { #ifdef USE_OSD if(sh_video) { @@ -3367,7 +3410,7 @@ #ifdef USE_SUB set_of_sub_pos = -1; subdata = NULL; - vo_sub = NULL; + vo_sub_last = vo_sub = NULL; #endif vobsub_id = -1; dvdsub_id = -1; @@ -4008,6 +4051,7 @@ if (pts > sub_last_pts || pts < sub_last_pts-1.0 ) { find_sub(subdata, (pts+sub_delay) * (subdata->sub_uses_time ? 100. : sub_fps)); + if (vo_sub) vo_sub_last = vo_sub; // FIXME! frame counter... sub_last_pts = pts; } @@ -4110,7 +4154,7 @@ for (i = 0; i < set_of_sub_size; ++i) sub_free( set_of_subtitles[i] ); set_of_sub_size = 0; - vo_sub=NULL; + vo_sub_last = vo_sub=NULL; subdata=NULL; } #endif