diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-04-18 13:39:33 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-04-23 16:49:48 +0200 |
| commit | 9f828b327e680c322a70883910233337a37e481e (patch) | |
| tree | e7fb8e4c3ef3ed6324cc1a9e25fd97af3c8bd5e1 /src/lib/ffmpeg_decoder.h | |
| parent | 2666e3232a9520c3b0fa94c48a689880cdde13fc (diff) | |
Fix late subtitles when they are muxed late with respect to the video.
In one example we have the sequence
video 3088,377
sub 3087,334
sub 3088,710
video 3088,419
so the 3087,334 sub is very late. Here we insert a queue to bring
subtitle packets a little forward for processing.
There is already a similar thing in the player (_delay) but adding
a longer delay there seems wasteful because a) the video is by
that point already decompressed and b) this problem only
applies to FFmpeg-decoded files (and then, I think only if we are
previewing or burning in subtitles).
Diffstat (limited to 'src/lib/ffmpeg_decoder.h')
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 498bb11a8..795320280 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -27,6 +27,7 @@ #include "bitmap_text.h" #include "decoder.h" #include "ffmpeg.h" +#include "packet_queue.h" #include "video_filter_graph_set.h" extern "C" { #include <libavcodec/avcodec.h> @@ -39,6 +40,7 @@ class AudioBuffers; class FFmpegAudioStream; class Image; class Log; +class PacketQueue; class VideoFilterGraph; struct ffmpeg_pts_offset_test; @@ -64,6 +66,7 @@ private: }; FlushResult flush(); + bool process_from_packet_queue(bool flushing); AVSampleFormat audio_sample_format(std::shared_ptr<FFmpegAudioStream> stream) const; int bytes_per_audio_sample(std::shared_ptr<FFmpegAudioStream> stream) const; @@ -97,12 +100,14 @@ private: std::map<std::shared_ptr<FFmpegAudioStream>, boost::optional<dcpomatic::ContentTime>> _next_time; enum class FlushState { + PACKET_QUEUE, CODECS, AUDIO_DECODER, FILL, }; - FlushState _flush_state = FlushState::CODECS; + FlushState _flush_state = FlushState::PACKET_QUEUE; std::vector<boost::optional<dcpomatic::ContentTime>> _dropped_time; + std::unique_ptr<PacketQueue> _packet_queue; }; |
