fix(video): skip startup black frames
Some checks failed
Mirror to GitHub / mirror (push) Failing after 29s
Build Release Binaries / build-amd64 (push) Failing after 3m2s

This commit is contained in:
Siavash Sameni
2026-05-25 21:35:00 +04:00
parent d2046060b5
commit ee654cd1ef
2 changed files with 158 additions and 84 deletions

View File

@@ -605,10 +605,12 @@ const remoteCtx = vdRemoteVideo.getContext("2d")!;
const vdRemotePlaceholder = document.getElementById("vd-remote-placeholder")!;
const vdRemoteCounter = document.getElementById("vd-remote-counter")!;
let remoteFrameCount = 0;
let remoteFrameSerial = 0;
listen("video:frame", (event: any) => {
const { width, height, jpeg_b64 } = event.payload;
if (!jpeg_b64) return;
const frameSerial = ++remoteFrameSerial;
remoteVideoActive = true;
vdVideoStrip.classList.remove("hidden");
@@ -620,6 +622,7 @@ listen("video:frame", (event: any) => {
const img = new Image();
img.onload = () => {
if (frameSerial !== remoteFrameSerial) return;
remoteCtx.drawImage(img, 0, 0, vdRemoteVideo.width, vdRemoteVideo.height);
};
img.src = `data:image/jpeg;base64,${jpeg_b64}`;