Skip to content

Commit 763c187

Browse files
Merge pull request #281 from GuilhermeFaga/main
fix(#264): read raw pixels from canvas for VideoFrame to avoid silent failures on Linux
2 parents 20567db + 914a3c7 commit 763c187

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
@@ -232,8 +232,16 @@ export class VideoExporter {
232232

233233
const canvas = renderer.getCanvas();
234234

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

0 commit comments

Comments
 (0)