diff options
author | wm4 <wm4@nowhere> | 2013-06-11 21:39:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-23 22:33:59 +0200 |
commit | a70d575291d48289669ee8989e0597a94189dd8d (patch) | |
tree | fd2ddf88485e40e77183ac8aceb68a7557ddfa49 /core/mplayer.c | |
parent | a792f0d628ea6170ce351fc816a2d71e276a8c49 (diff) | |
download | mpv-a70d575291d48289669ee8989e0597a94189dd8d.tar.bz2 mpv-a70d575291d48289669ee8989e0597a94189dd8d.tar.xz |
sub: preload external text subtitles
If a subtitle is external, read it completely and add all subtitle
events in advance when the subtitle track is selected. This is done
for text subtitles only. (Note that subreader.c and subtitles loaded
with libass are different and don't have anything to do with this
commit.)
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index d9c577b354..3f65573bb5 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2036,12 +2036,22 @@ static void reinit_subs(struct MPContext *mpctx) if (!sub_is_initialized(dec_sub)) { int w = mpctx->sh_video ? mpctx->sh_video->disp_w : 0; int h = mpctx->sh_video ? mpctx->sh_video->disp_h : 0; + float fps = mpctx->sh_video ? mpctx->sh_video->fps : 25; set_dvdsub_fake_extradata(dec_sub, track->demuxer->stream, w, h); sub_set_video_res(dec_sub, w, h); + sub_set_video_fps(dec_sub, fps); sub_set_ass_renderer(dec_sub, mpctx->osd->ass_library, mpctx->osd->ass_renderer); sub_init_from_sh(dec_sub, sh_sub); + + // Don't do this if the file has video/audio streams. Don't do it even + // if it has only sub streams, because reading packets will change the + // demuxer position. + if (!track->preloaded && track->is_external) { + demux_seek(track->demuxer, 0, 0, SEEK_ABSOLUTE); + track->preloaded = sub_read_all_packets(dec_sub, sh_sub); + } } mpctx->osd->dec_sub = dec_sub; |