From 914a3c7f7b7434ead4a02a9fb41edb7037b1fc90 Mon Sep 17 00:00:00 2001 From: Faga Date: Thu, 2 Apr 2026 11:55:21 -0300 Subject: [PATCH] fix: read raw pixels from canvas for VideoFrame to avoid silent failures on Linux --- src/lib/exporter/videoExporter.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.ts index 1b75a2e..efdfcfb 100644 --- a/src/lib/exporter/videoExporter.ts +++ b/src/lib/exporter/videoExporter.ts @@ -230,8 +230,16 @@ export class VideoExporter { const canvas = renderer.getCanvas(); - // @ts-expect-error - colorSpace is available at runtime even if TS does not know it. - const exportFrame = new VideoFrame(canvas, { + // Read raw pixels from the canvas instead of passing + // the canvas directly to VideoFrame. On some Linux + // systems the GPU shared-image path (EGL/Ozone) fails + // silently, producing empty frames. + const canvasCtx = canvas.getContext("2d")!; + const imageData = canvasCtx.getImageData(0, 0, canvas.width, canvas.height); + const exportFrame = new VideoFrame(imageData.data.buffer, { + format: "RGBA", + codedWidth: canvas.width, + codedHeight: canvas.height, timestamp, duration: frameDuration, colorSpace: {