From 9bd8b3304f35f0b27bf18f2167302f1fd5d3f92b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 7 Dec 2025 02:17:34 +0100 Subject: Try AVSEEK_FLAG_ANY if _BACKWARD fails. We usually want to do _BACKWARD as this should seek to the keyframe before the seek position. On some files this fails, and then it seems that _ANY is a good next thing to try. --- test/ffmpeg_decoder_seek_test.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ffmpeg_decoder_seek_test.cc') diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc index 43967e458..ee0da99da 100644 --- a/test/ffmpeg_decoder_seek_test.cc +++ b/test/ffmpeg_decoder_seek_test.cc @@ -133,3 +133,22 @@ BOOST_AUTO_TEST_CASE(ffmpeg_decoder_seek_test) } ); } + + +BOOST_AUTO_TEST_CASE(seek_when_backward_fails) +{ + auto content = make_shared(TestPaths::private_data() / "strange_keyframes.mp4"); + auto film = new_test_film("seek_when_backward_fails", { content }); + auto decoder = make_shared(film, content, false); + decoder->video->Data.connect(bind(&store, _1)); + + /* Due to a bug this seek would fail silently, giving us different frame each time */ + for (auto i = 0; i < 3; ++i) { + decoder->seek(dcpomatic::ContentTime(), true); + stored = {}; + while (!decoder->pass() && !stored) {} + BOOST_REQUIRE(static_cast(stored)); + BOOST_CHECK(stored->time == dcpomatic::ContentTime()); + } +} + -- cgit v1.2.3