From bf16f6f4f329b7903ba550c458545fbdb41f5314 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 21:21:58 +0000 Subject: Make update_subtitles work without sh_video for text subtitles. This fixes a crash with e.g. auto-enabled subtitles and -novideo due to command.c calling update_subtitles even without video and is a step toward subtitle support for audio-only files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29710 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 59a0b48a7f..7064223e09 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1767,7 +1767,7 @@ static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video) current_module = "decode video"; decoded_frame = decode_video(sh_video, start, in_size, drop_frame, pts); if (decoded_frame) { - update_subtitles(sh_video, mpctx->d_sub, 0); + update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0); update_teletext(sh_video, mpctx->demuxer, 0); update_osd_msg(); current_module = "filter video"; @@ -2290,7 +2290,7 @@ static double update_video(int *blit_frame) // video_read_frame can change fps (e.g. for ASF video) vo_fps = sh_video->fps; drop_frame = check_framedrop(frame_time); - update_subtitles(sh_video, mpctx->d_sub, 0); + update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0); update_teletext(sh_video, mpctx->demuxer, 0); update_osd_msg(); current_module = "decode_video"; @@ -2483,7 +2483,7 @@ static int seek(MPContext *mpctx, double amount, int style) // (which is used by at least vobsub and edl code below) may // be completely wrong (probably 0). mpctx->sh_video->pts = mpctx->d_video->pts; - update_subtitles(mpctx->sh_video, mpctx->d_sub, 1); + update_subtitles(mpctx->sh_video, mpctx->sh_video->pts, mpctx->d_sub, 1); update_teletext(mpctx->sh_video, mpctx->demuxer, 1); } -- cgit v1.2.3 From 4b182ff652ee52647913a065801df12c99989173 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 21:48:48 +0000 Subject: Add support for displaying subtitles on the command-line when playing audio-only files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29712 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 7064223e09..aa59ab7088 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1507,6 +1507,26 @@ void set_osd_bar(int type,const char* name,double min,double max,double val) { name,ROUND(100*(val-min)/(max-min))); } +/** + * \brief Display text subtitles on the OSD + */ +void set_osd_subtitle(subtitle *subs) { + int i; + vo_sub = subs; + vo_osd_changed(OSDTYPE_SUBTITLE); + if (!mpctx->sh_video) { + // reverse order, since newest set_osd_msg is displayed first + for (i = SUB_MAX_TEXT - 1; i >= 0; i--) { + if (!subs || i >= subs->lines || !subs->text[i]) + rm_osd_msg(OSD_MSG_SUB_BASE + i); + else { + // HACK: currently display time for each sub line except the last is set to 2 seconds. + int display_time = i == subs->lines - 1 ? 180000 : 2000; + set_osd_msg(OSD_MSG_SUB_BASE + i, 1, display_time, "%s", subs->text[i]); + } + } + } +} /** * \brief Update the OSD message line. @@ -2492,6 +2512,8 @@ static int seek(MPContext *mpctx, double amount, int style) mpctx->audio_out->reset(); // stop audio, throwing away buffered data mpctx->sh_audio->a_buffer_len = 0; mpctx->sh_audio->a_out_buffer_len = 0; + if (!mpctx->sh_video) + update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 1); } if (vo_vobsub && mpctx->sh_video) { @@ -3704,6 +3726,7 @@ if(!mpctx->sh_video) { if(end_at.type == END_AT_TIME && end_at.pos < a_pos) mpctx->eof = PT_NEXT_ENTRY; + update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 0); update_osd_msg(); } else { -- cgit v1.2.3 From 95d60aa0190533226974a46fd612fd6face91b7b Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 28 Sep 2009 11:24:13 +0000 Subject: Use a_pos to update subtitle for audio-only files instead of mpctx->sh_audio->pts which e.g. for mp3 in AVI never has a useful value. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29727 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index aa59ab7088..42174cf2c1 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3726,7 +3726,7 @@ if(!mpctx->sh_video) { if(end_at.type == END_AT_TIME && end_at.pos < a_pos) mpctx->eof = PT_NEXT_ENTRY; - update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 0); + update_subtitles(NULL, a_pos, mpctx->d_sub, 0); update_osd_msg(); } else { -- cgit v1.2.3 From f43cc7c3cc86c02ccdf703398238200a81d6ac86 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 28 Sep 2009 11:26:19 +0000 Subject: Enable loading of external subtitles also for audio-only files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29728 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 42174cf2c1..7480a7b665 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3450,14 +3450,15 @@ if(vo_spudec==NULL && mpctx->sh_video && init_vo_spudec(); } -if(mpctx->sh_video) { +if(1 || mpctx->sh_video) { // after reading video params we should load subtitles because // we know fps so now we can adjust subtitle time to ~6 seconds AST // check .sub + double fps = mpctx->sh_video ? mpctx->sh_video->fps : 25; current_module="read_subtitles_file"; if(sub_name){ for (i = 0; sub_name[i] != NULL; ++i) - add_subtitles (sub_name[i], mpctx->sh_video->fps, 0); + add_subtitles (sub_name[i], fps, 0); } if(sub_auto) { // auto load sub file ... char *psub = get_path( "sub/" ); @@ -3465,7 +3466,7 @@ if(mpctx->sh_video) { int i = 0; free(psub); // release the buffer created by get_path() above while (tmp[i]) { - add_subtitles (tmp[i], mpctx->sh_video->fps, 1); + add_subtitles (tmp[i], fps, 1); free(tmp[i++]); } free(tmp); -- cgit v1.2.3 From e3625bd232a27113c4f6d1e68815da94630ba29c Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 28 Sep 2009 11:32:27 +0000 Subject: Add a -nosub option that allows disabling auto-selected subtitles as e.g. the mkv demuxer supports. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29730 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 7480a7b665..d5ce13cf95 100644 --- a/mplayer.c +++ b/mplayer.c @@ -253,7 +253,7 @@ extern char *sub_demuxer_name; // override sub demuxer // streaming: int audio_id=-1; int video_id=-1; -int dvdsub_id=-2; +int dvdsub_id=-1; int vobsub_id=-1; char* audio_lang=NULL; char* dvdsub_lang=NULL; @@ -3491,11 +3491,11 @@ if (mpctx->global_sub_size) { } else if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] >= 0) { // if there are text subs to use, use those. (autosubs come last here) mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_SUBS]; - } else if (dvdsub_id < 0 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { + } else if (dvdsub_id == -1 && mpctx->global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { // finally select subs by language and container hints - if (dvdsub_id < 0 && dvdsub_lang) + if (dvdsub_id == -1 && dvdsub_lang) dvdsub_id = demuxer_sub_track_by_lang(mpctx->demuxer, dvdsub_lang); - if (dvdsub_id < 0) + if (dvdsub_id == -1) dvdsub_id = demuxer_default_sub_track(mpctx->demuxer); if (dvdsub_id >= 0) mpctx->global_sub_pos = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id; -- cgit v1.2.3 From 6fa7e2d8670efd6b157d230fd528df32df213785 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 29 Sep 2009 06:44:10 +0000 Subject: Make -nosub work to disable subtitles even if -slang and dvd streams are used. This still needs some additional checking that subtitle selection via dvdnav works. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29732 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index d5ce13cf95..90ecea84a5 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3204,7 +3204,6 @@ if(stream_dump_type==5){ if(mpctx->stream->type==STREAMTYPE_DVD){ current_module="dvd lang->id"; if(audio_id==-1) audio_id=dvd_aid_from_lang(mpctx->stream,audio_lang); - if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1; if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(mpctx->stream,dvdsub_lang); // setup global sub numbering mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub. @@ -3217,7 +3216,6 @@ if(mpctx->stream->type==STREAMTYPE_DVD){ if(mpctx->stream->type==STREAMTYPE_DVDNAV){ current_module="dvdnav lang->id"; if(audio_id==-1) audio_id=mp_dvdnav_aid_from_lang(mpctx->stream,audio_lang); - if(dvdsub_lang && dvdsub_id==-2) dvdsub_id=-1; if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=mp_dvdnav_sid_from_lang(mpctx->stream,dvdsub_lang); // setup global sub numbering mpctx->global_sub_indices[SUB_SOURCE_DEMUX] = mpctx->global_sub_size; // the global # of the first demux-specific sub. -- cgit v1.2.3