diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp
index 96cf4e06..e46f03c6 100644
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -1057,13 +1057,26 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame) {
// Check if largest frame is still cached
frame = final_cache.GetFrame(largest_frame_processed);
+ int samples_in_frame = Frame::GetSamplesPerFrame(requested_frame, info.fps,
+ info.sample_rate, info.channels);
if (frame) {
- // return the largest processed frame (assuming it was the last in the video file)
+ // Copy and return the largest processed frame (assuming it was the last in the video file)
+ std::shared_ptr f = CreateFrame(largest_frame_processed);
+
+ // Use solid color (if no image data found)
+ if (!frame->has_image_data) {
+ // Use solid black frame if no image data available
+ f->AddColor(info.width, info.height, "#000");
+ }
+ // Silence audio data (if any), since we are repeating the last frame
+ frame->AddAudioSilence(samples_in_frame);
+
return frame;
} else {
// The largest processed frame is no longer in cache, return a blank frame
std::shared_ptr f = CreateFrame(largest_frame_processed);
f->AddColor(info.width, info.height, "#000");
+ f->AddAudioSilence(samples_in_frame);
return f;
}
}