summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/tech/slave.txt6
-rw-r--r--input/input.c1
-rw-r--r--input/input.h1
-rw-r--r--mplayer.c48
4 files changed, 54 insertions, 2 deletions
diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt
index 4859e84458..f6674cd0c1 100644
--- a/DOCS/tech/slave.txt
+++ b/DOCS/tech/slave.txt
@@ -101,6 +101,12 @@ sub_select
-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.
diff --git a/input/input.c b/input/input.c
index 5c8a025e17..0731e679c1 100644
--- a/input/input.c
+++ b/input/input.c
@@ -79,6 +79,7 @@ static mp_cmd_t mp_cmds[] = {
{ 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
diff --git a/input/input.h b/input/input.h
index 62c04e3d5d..26a0d83ea5 100644
--- a/input/input.h
+++ b/input/input.h
@@ -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
diff --git a/mplayer.c b/mplayer.c
index 0c7b9c4a4a..92372cae18 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -754,6 +754,7 @@ int sub_source()
#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 @@ static int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data)
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 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
}
#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 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
#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 ((user_muted | edl_muted) != mixer.muted) mixer_mute(&mixer);
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 @@ uninit_player(INITED_ALL-(INITED_GUI+INITED_INPUT+(fixed_vo?INITED_VO:0)));
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