summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-10-31 18:16:30 +0100
committerwm4 <wm4@nowhere>2013-10-31 18:17:14 +0100
commit2537f6f4670cf1924eaa40153e4b858e7aa66df5 (patch)
tree0339c0292969ec351b0d117ad4d6ef517e80830d /sub
parent75261165afb5de2bed11947ffdd7dacfd3705e38 (diff)
downloadmpv-2537f6f4670cf1924eaa40153e4b858e7aa66df5.tar.bz2
mpv-2537f6f4670cf1924eaa40153e4b858e7aa66df5.tar.xz
sd_lavc: display DVD subs with unknown duration
DVD subs (rarely) have subtitle events without end timestamp. The duration is unknown, and they should be displayed until they're replaced by the next event. FFmpeg fails hard to make us aware whether duration is unknown or actually 0, so we can't distinguish between these two cases. It fails at this twice: AVPacket.duration is set to 0 if duration is unknown, and AVSubtitle.end_display_time has the same issue. Add a hack that considers all bitmap subtitles with duration==0 as events with uknown length. I'd rather accidentally display a hidden subtitle (if they exist at all), instead of not displaying random subtitles at all. See github issue #325.
Diffstat (limited to 'sub')
-rw-r--r--sub/sd_lavc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index a906e72f10..b03861025d 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -136,6 +136,12 @@ static void decode(struct sd *sd, struct demux_packet *packet)
AVSubtitle sub;
AVPacket pkt;
+ // libavformat sets duration==0, even if the duration is unknown.
+ // Assume there are no bitmap subs that actually use duration==0 for
+ // hidden subtitle events.
+ if (duration == 0)
+ duration = -1;
+
clear(priv);
av_init_packet(&pkt);
pkt.data = packet->buffer;