summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-12-12 11:43:45 +0100
committerCarl Hetherington <cth@carlh.net>2025-12-15 00:20:53 +0100
commit52b3eee4e7285e26469b2a5f4d9d9eac20aba387 (patch)
treef3741553ff125d7b47a2893e1cc2904606286dfa
parent27ba3d15cc2bc70f926b6ee8c43662a968faa29b (diff)
Fix error when seeking a file with no video and >1 audio stream (#3128).
-rw-r--r--src/lib/ffmpeg_decoder.cc9
m---------test/data0
-rw-r--r--test/ffmpeg_decoder_seek_test.cc22
3 files changed, 26 insertions, 5 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index c70733c4c..ec85bb56c 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -418,11 +418,10 @@ FFmpegDecoder::seek (ContentTime time, bool accurate)
if (_video_stream) {
stream = _video_stream;
} else {
- DCPOMATIC_ASSERT (_ffmpeg_content->audio);
- auto s = dynamic_pointer_cast<FFmpegAudioStream>(_ffmpeg_content->audio->stream());
- if (s) {
- stream = s->index (_format_context);
- }
+ DCPOMATIC_ASSERT(_ffmpeg_content->audio);
+ auto streams = _ffmpeg_content->ffmpeg_audio_streams();
+ DCPOMATIC_ASSERT(!streams.empty());
+ stream = streams[0]->index(_format_context);
}
DCPOMATIC_ASSERT (stream);
diff --git a/test/data b/test/data
-Subproject 7bc927ee1c828ce5f6f8e376176c8a44f193ed1
+Subproject 090abdff0d1f62f363792a13982d836f891b390
diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc
index ee0da99da..a3212318c 100644
--- a/test/ffmpeg_decoder_seek_test.cc
+++ b/test/ffmpeg_decoder_seek_test.cc
@@ -28,6 +28,8 @@
*/
+#include "lib/audio_decoder.h"
+#include "lib/content_audio.h"
#include "lib/content_video.h"
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_decoder.h"
@@ -152,3 +154,23 @@ BOOST_AUTO_TEST_CASE(seek_when_backward_fails)
}
}
+
+BOOST_AUTO_TEST_CASE(seek_with_no_video_two_audio)
+{
+ auto content = make_shared<FFmpegContent>("test/data/no_video_two_audio.mov");
+ auto film = new_test_film("seek_with_no_video_two_audio", { content });
+ auto decoder = make_shared<FFmpegDecoder>(film, content, false);
+
+ optional<Frame> frame;
+ auto audio = [&](AudioStreamPtr, ContentAudio audio) {
+ frame = audio.frame;
+ };
+
+ decoder->audio->Data.connect(boost::bind<void>(audio, _1, _2));
+ decoder->seek(dcpomatic::ContentTime::from_seconds(1), false);
+ while (!decoder->pass() && frame == boost::none) {}
+
+ BOOST_REQUIRE(frame != boost::none);
+ BOOST_CHECK(*frame > 0);
+}
+