Skip to content

Commit 914a3c7

Browse files
committed
fix: read raw pixels from canvas for VideoFrame to avoid silent failures on Linux
1 parent 2f36160 commit 914a3c7

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/lib/exporter/videoExporter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,16 @@ export class VideoExporter {
230230

231231
const canvas = renderer.getCanvas();
232232

233-
// @ts-expect-error - colorSpace is available at runtime even if TS does not know it.
234-
const exportFrame = new VideoFrame(canvas, {
233+
// Read raw pixels from the canvas instead of passing
234+
// the canvas directly to VideoFrame. On some Linux
235+
// systems the GPU shared-image path (EGL/Ozone) fails
236+
// silently, producing empty frames.
237+
const canvasCtx = canvas.getContext("2d")!;
238+
const imageData = canvasCtx.getImageData(0, 0, canvas.width, canvas.height);
239+
const exportFrame = new VideoFrame(imageData.data.buffer, {
240+
format: "RGBA",
241+
codedWidth: canvas.width,
242+
codedHeight: canvas.height,
235243
timestamp,
236244
duration: frameDuration,
237245
colorSpace: {

0 commit comments

Comments
 (0)