diff --git a/crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs b/crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs index e77ca0d563cd2..cf4fb3a687396 100644 --- a/crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs +++ b/crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs @@ -884,7 +884,10 @@ impl AsyncDecoder for FFmpegCliH264Decoder { } fn min_num_samples_to_enqueue_ahead(&self) -> usize { - // TODO: describe this and add ticket. + // TODO(#8848): On some videos (which??) we need to enqueue more samples, otherwise ffmpeg will not provide us with any frames. + // The observed behavior is that we continously get frames that are 16 frames older than what we enqueued, + // never reaching the frames of all currently enqueued GOPs prior. + // (The same happens with webcodec decoder on Safari for affected videos) 16 } } diff --git a/crates/utils/re_video/src/decode/webcodecs.rs b/crates/utils/re_video/src/decode/webcodecs.rs index 5f54376c10a7d..2522155e13d29 100644 --- a/crates/utils/re_video/src/decode/webcodecs.rs +++ b/crates/utils/re_video/src/decode/webcodecs.rs @@ -190,8 +190,28 @@ impl AsyncDecoder for WebVideoDecoder { Ok(()) } + + fn min_num_samples_to_enqueue_ahead(&self) -> usize { + // TODO(#8848): For some h264 videos (which??) we need to enqueue more samples, otherwise Safari will not provide us with any frames. + // (The same happens with FFmpeg-cli decoder for the affected videos) + if self.video_config.is_h264() && IS_SAFARI.get() { + { + 16 // Safari needs more samples queued for h264 + } else { + // No such workaround are needed anywhere else, + // GOP boundaries as handled by the video player are enough. + 0 + } + } } +const IS_SAFARI: Lazy = Lazy::new(|| { + web_sys::window() + .and_then(|w| w.navigator().user_agent().ok()) + .map(|ua| ua.contains("Safari")) + .unwrap_or(false) +}); + fn init_video_decoder( on_output_callback: Arc, timescale: Timescale,