Skip to content

Commit 0dc117c

Browse files
committed
Use dynamic timeout based on resolution
1 parent 26e9424 commit 0dc117c

File tree

1 file changed

+12
-2
lines changed
  • crates/rendering/src/decoder

1 file changed

+12
-2
lines changed

crates/rendering/src/decoder/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,21 @@ pub struct AsyncVideoDecoderHandle {
456456
}
457457

458458
impl AsyncVideoDecoderHandle {
459-
const NORMAL_TIMEOUT_MS: u64 = 2000;
460459
const INITIAL_SEEK_TIMEOUT_MS: u64 = 10000;
461460

461+
fn normal_timeout_ms(&self) -> u64 {
462+
let pixels = (self.status.video_width as u64) * (self.status.video_height as u64);
463+
if pixels > 4_000_000 {
464+
4000
465+
} else if pixels > 2_000_000 {
466+
3000
467+
} else {
468+
2000
469+
}
470+
}
471+
462472
pub async fn get_frame(&self, time: f32) -> Option<DecodedFrame> {
463-
self.get_frame_with_timeout(time, Self::NORMAL_TIMEOUT_MS)
473+
self.get_frame_with_timeout(time, self.normal_timeout_ms())
464474
.await
465475
}
466476

0 commit comments

Comments
 (0)