diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-10-25 00:41:42 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-10-25 01:14:36 +0200 |
| commit | fff2c8e7ec45cd4473c0753d67e06ee5b589717b (patch) | |
| tree | c14d15795e2cdf1f969b930a409b71bc4633bc5a /src/lib | |
| parent | 0e032143cee2a5253d7e940b6f0c84df9d900897 (diff) | |
If there is no end time in an AVSubtitle it seems we should use the AVPacket's duration.
This fixes #2110. I don't have a particular justification for it being
the right thing to do.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 503f8e51c..eed9ab94c 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -287,16 +287,18 @@ FFmpegSubtitlePeriod FFmpeg::subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub) { auto const packet_time = ContentTime::from_seconds (packet->pts * av_q2d(stream->time_base)); + auto const start = packet_time + ContentTime::from_seconds(sub.start_display_time / 1e3); if (sub.end_display_time == 0 || sub.end_display_time == static_cast<uint32_t>(-1)) { - /* End time is not known */ - return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3)); + /* End time is not in the AVSubtitle; perhaps we can use the AVPacket's duration */ + if (packet->duration) { + return FFmpegSubtitlePeriod(start, start + ContentTime::from_seconds(packet->duration * av_q2d(stream->time_base))); + } else { + return FFmpegSubtitlePeriod(start); + } } - return FFmpegSubtitlePeriod ( - packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3), - packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3) - ); + return FFmpegSubtitlePeriod (start, packet_time + ContentTime::from_seconds(sub.end_display_time / 1e3)); } |
