Skip to content

Commit

Permalink
extend hack to safari
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jan 29, 2025
1 parent af15d5e commit b830460
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 888 in crates/utils/re_video/src/decode/ffmpeg_h264/ffmpeg.rs

View workflow job for this annotation

GitHub Actions / Checks / Spell Check

"continously" should be "continuously".
// never reaching the frames of all currently enqueued GOPs prior.
// (The same happens with webcodec decoder on Safari for affected videos)
16
}
}
Expand Down
20 changes: 20 additions & 0 deletions crates/utils/re_video/src/decode/webcodecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> = 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<OutputCallback>,
timescale: Timescale,
Expand Down

0 comments on commit b830460

Please sign in to comment.