{"record":{"id":"5e06b4348ee7d3d2","repo":"remotion-dev/remotion","slug":"mediabunny-did-not-return-an-output-buffer","errorCode":null,"errorMessage":"Mediabunny did not return an output buffer.","messagePattern":"Mediabunny did not return an output buffer\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/canvas-capture-extension/src/recorder.ts","lineNumber":336,"sourceCode":"const finalizeRecording = async (\n\trecording: RecordingState,\n\tfilename: string,\n\tformat: CaptureFormat,\n): Promise<File> => {\n\tawait recording.lastFramePromise;\n\tif (recording.hasEncodingError) {\n\t\tthrow recording.encodingError;\n\t}\n\n\tif (recording.frameCount === 0) {\n\t\tthrow new Error('No frames were added to the canvas recording.');\n\t}\n\n\trecording.source.close();\n\tawait recording.output.finalize();\n\n\tif (!recording.target.buffer) {\n\t\tthrow new Error('Mediabunny did not return an output buffer.');\n\t}\n\n\tconst captureData = JSON.stringify({\n\t\tstartedAt: recording.startedAt,\n\t\tendedAt: performance.now(),\n\t\tcaptureMetadata: recording.captureMetadata,\n\t\tmouseMovements: recording.mouseMovements,\n\t\tpointerClicks: recording.pointerClicks,\n\t});\n\n\tconst {\n\t\tALL_FORMATS,\n\t\tBufferSource,\n\t\tBufferTarget,\n\t\tConversion,\n\t\tInput,\n\t\tMp4OutputFormat,\n\t\tOutput,","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/canvas-capture-extension/src/recorder.ts#L318-L354","documentation":"After `recording.source.close()` and `await recording.output.finalize()`, the code expects `recording.target.buffer` to be populated by Mediabunny's `BufferTarget`. If the buffer is falsy, finalization produced no data. This is a defensive guard against Mediabunny silently returning an empty result despite a successful finalize.","triggerScenarios":"Mediabunny's `BufferTarget` did not accumulate bytes — e.g., the muxer/encoder produced no output despite frameCount > 0; a Mediabunny version mismatch or internal error left the buffer undefined; finalize resolved but never wrote to the target.","commonSituations":"Mediabunny version regression; encoding silently dropped samples; a corrupted Mediabunny build; an unsupported codec configuration that did not raise `encodingError`.","solutions":["Upgrade or pin a known-good Mediabunny version.","Inspect `recording.encodingError` and `hasEncodingError` for the real cause.","Re-run the capture; if persistent, capture debug info from the Mediabunny conversion.","Report with the Mediabunny version and capture parameters."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await recorder.stopRecording();\n} catch (e) {\n  if (e instanceof Error && /did not return an output buffer/.test(e.message)) {\n    logMediabunnyVersion();\n    // re-record with a fresh session; do not reuse state.\n  }\n  throw e;\n}","preventionTips":["Pin a known-good Mediabunny version.","Check encodingError before stopping.","Capture Mediabunny warnings during finalize."],"tags":["canvas-capture","mediabunny","encoding","buffer"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}