From 60450bd93af0b331d7b98c88aa199366305f0721 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 12 Sep 2021 22:43:52 +0200 Subject: Fix missing subtitles embedded in files decoded by FFmpeg (#2060). Since the FFmpeg 4.4 update it seems that AVSubtitle::pts is no longer set (it's AV_NOPTS_VALUE, i think). Instead we apparently need to get the PTS from the packet, which in turn requires the stream's timebase. --- src/lib/ffmpeg_decoder.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 3202dcd3e..72372fca8 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -622,12 +622,14 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) return; } + auto sub_period = subtitle_period (packet, ffmpeg_content()->subtitle_stream()->stream(_format_context), sub); + /* Stop any current subtitle, either at the time it was supposed to stop, or now if now is sooner */ if (_have_current_subtitle) { if (_current_subtitle_to) { - only_text()->emit_stop (min(*_current_subtitle_to, subtitle_period(sub).from + _pts_offset)); + only_text()->emit_stop (min(*_current_subtitle_to, sub_period.from + _pts_offset)); } else { - only_text()->emit_stop (subtitle_period(sub).from + _pts_offset); + only_text()->emit_stop (sub_period.from + _pts_offset); } _have_current_subtitle = false; } @@ -641,7 +643,6 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) /* Subtitle PTS (within the source, not taking into account any of the source that we may have chopped off for the DCP). */ - auto sub_period = subtitle_period (sub); ContentTime from; from = sub_period.from + _pts_offset; if (sub_period.to) { -- cgit v1.2.3