mirror of
https://github.com/mpv-player/mpv
synced 2025-02-11 15:24:30 +01:00
command to log current subtitle to file
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14685 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ce168139ad
commit
65ad39a096
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
48
mplayer.c
48
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[]){
|
||||
|
||||
|
||||
@ -2859,6 +2897,11 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
||||
step_sub(subdata, sh_video->pts, movement);
|
||||
osd_show_sub_delay = 9; // show the subdelay in OSD
|
||||
}
|
||||
#endif
|
||||
} break;
|
||||
case MP_CMD_SUB_LOG : {
|
||||
#ifdef USE_SUB
|
||||
log_sub();
|
||||
#endif
|
||||
} break;
|
||||
case MP_CMD_OSD : {
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user