summaryrefslogtreecommitdiffstats
path: root/sub/sd_lavc.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-09-09 04:16:32 +0200
committerDudemanguy <random342@airmail.cc>2023-09-11 01:58:07 +0000
commit8536aaac3c2c22b77a596d0645ac99be20c0186a (patch)
tree95061e0159ac09fee1f83415ffb6f1960915bbf6 /sub/sd_lavc.c
parentf5690e3c9765e138683ba313c696704c54396317 (diff)
downloadmpv-8536aaac3c2c22b77a596d0645ac99be20c0186a.tar.bz2
mpv-8536aaac3c2c22b77a596d0645ac99be20c0186a.tar.xz
sd_lavc: fix subtitle presentation time
Packet duration is not necessarily related to the display time of the subtitle. Use start/end_display_time fields as source of the timing. Fixes subtitles with infinite duration that should be on screen until next sub is displayed.
Diffstat (limited to 'sub/sd_lavc.c')
-rw-r--r--sub/sd_lavc.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 43dbfeee00..30aa641437 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -300,17 +300,8 @@ static void decode(struct sd *sd, struct demux_packet *packet)
AVCodecContext *ctx = priv->avctx;
double pts = packet->pts;
double endpts = MP_NOPTS_VALUE;
- double duration = packet->duration;
AVSubtitle sub;
- // libavformat sets duration==0, even if the duration is unknown. Some files
- // also have actually subtitle packets with duration explicitly set to 0
- // (yes, at least some of such mkv files were muxed by libavformat).
- // Assume there are no bitmap subs that actually use duration==0 for
- // hidden subtitle events.
- if (duration == 0)
- duration = -1;
-
if (pts == MP_NOPTS_VALUE)
MP_WARN(sd, "Subtitle with unknown start time.\n");
@@ -334,13 +325,10 @@ static void decode(struct sd *sd, struct demux_packet *packet)
if (sub.end_display_time > sub.start_display_time &&
sub.end_display_time != UINT32_MAX)
{
- duration = (sub.end_display_time - sub.start_display_time) / 1000.0;
+ endpts = pts + sub.end_display_time / 1000.0;
}
pts += sub.start_display_time / 1000.0;
- if (duration >= 0)
- endpts = pts + duration;
-
// set end time of previous sub
struct sub *prev = &priv->subs[0];
if (prev->valid) {