Skip to content

Commit b830460

Browse files
committed
extend hack to safari
1 parent af15d5e commit b830460

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,10 @@ impl AsyncDecoder for FFmpegCliH264Decoder {
884884
}
885885

886886
fn min_num_samples_to_enqueue_ahead(&self) -> usize {
887-
// TODO: describe this and add ticket.
887+
// TODO(#8848): On some videos (which??) we need to enqueue more samples, otherwise ffmpeg will not provide us with any frames.
888+
// The observed behavior is that we continously get frames that are 16 frames older than what we enqueued,
889+
// never reaching the frames of all currently enqueued GOPs prior.
890+
// (The same happens with webcodec decoder on Safari for affected videos)
888891
16
889892
}
890893
}

crates/utils/re_video/src/decode/webcodecs.rs

+20
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,28 @@ impl AsyncDecoder for WebVideoDecoder {
190190

191191
Ok(())
192192
}
193+
194+
fn min_num_samples_to_enqueue_ahead(&self) -> usize {
195+
// TODO(#8848): For some h264 videos (which??) we need to enqueue more samples, otherwise Safari will not provide us with any frames.
196+
// (The same happens with FFmpeg-cli decoder for the affected videos)
197+
if self.video_config.is_h264() && IS_SAFARI.get() {
198+
{
199+
16 // Safari needs more samples queued for h264
200+
} else {
201+
// No such workaround are needed anywhere else,
202+
// GOP boundaries as handled by the video player are enough.
203+
0
204+
}
205+
}
193206
}
194207

208+
const IS_SAFARI: Lazy<bool> = Lazy::new(|| {
209+
web_sys::window()
210+
.and_then(|w| w.navigator().user_agent().ok())
211+
.map(|ua| ua.contains("Safari"))
212+
.unwrap_or(false)
213+
});
214+
195215
fn init_video_decoder(
196216
on_output_callback: Arc<OutputCallback>,
197217
timescale: Timescale,

0 commit comments

Comments
 (0)