FFmpegSubtitlePeriod
-FFmpeg::subtitle_period (AVSubtitle const & sub)
+FFmpeg::subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub)
{
- auto const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
+ auto const packet_time = ContentTime::from_seconds (packet->pts * av_q2d(stream->time_base));
if (sub.end_display_time == static_cast<uint32_t> (-1)) {
/* End time is not known */
struct AVFormatContext;
struct AVFrame;
+struct AVStream;
struct AVIOContext;
class FFmpegContent;
std::vector<std::shared_ptr<FFmpegAudioStream>> audio_streams, boost::optional<dcpomatic::ContentTime> first_video, double video_frame_rate
) const;
- static FFmpegSubtitlePeriod subtitle_period (AVSubtitle const & sub);
+ static FFmpegSubtitlePeriod subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub);
std::shared_ptr<const FFmpegContent> _ffmpeg_content;
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;
}
/* 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) {