{"record":{"id":"8e157a8b3b9eb595","repo":"remotion-dev/remotion","slug":"outputs-base-and-outputs-foreground-must-not-use-t","errorCode":null,"errorMessage":"outputs.base and outputs.foreground must not use the same outputWritable.","messagePattern":"outputs\\.base and outputs\\.foreground must not use the same outputWritable\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/separate-video-layers.ts","lineNumber":192,"sourceCode":"\t\t\tArray.isArray(options.outputs))\n\t) {\n\t\tthrow new TypeError('outputs must be an object.');\n\t}\n\n\tvalidateLayerOutputOptions({\n\t\tlayer: 'base',\n\t\toutput: options.outputs?.base,\n\t});\n\tvalidateLayerOutputOptions({\n\t\tlayer: 'foreground',\n\t\toutput: options.outputs?.foreground,\n\t});\n\tif (\n\t\toptions.outputs?.base?.outputWritable !== undefined &&\n\t\toptions.outputs.base.outputWritable ===\n\t\t\toptions.outputs.foreground?.outputWritable\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'outputs.base and outputs.foreground must not use the same outputWritable.',\n\t\t);\n\t}\n\n\tgetVideoMattingModelInfo(options.model ?? 'modnet');\n\n\tif (\n\t\toptions.audio !== undefined &&\n\t\t!AUDIO_DESTINATIONS.includes(options.audio)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'audio must be one of base, foreground, both, or none.',\n\t\t);\n\t}\n\n\tresolveVideoMattingQuality(options.videoBitrate ?? 'very-high');\n\tresolveVideoMattingQuality(options.audioBitrate ?? 'medium');\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/separate-video-layers.ts#L174-L210","documentation":"Each layer's output must go to a distinct stream. If base and foreground both specify the same outputWritable instance, the two encoded tracks would interleave into one stream, so this TypeError is thrown.","triggerScenarios":"Reusing one WritableStream (or one TransformStream's writable side) for both outputs.base.outputWritable and outputs.foreground.outputWritable.","commonSituations":"Building outputs programmatically with a single shared stream variable; intending to write both layers to one file; copy-paste of the same stream reference.","solutions":["Create two separate WritableStreams, one per layer","Write to two files or two branches of a properly tee'd pipeline (tee produces READABLES, so pipe each branch through its own TransformStream)","Omit outputWritable for one layer and use outputPath/default handling instead"],"exampleFix":"// before\nconst shared = new WritableStream();\nawait separateVideoLayers({ src, outputs: { base: { outputWritable: shared }, foreground: { outputWritable: shared } } });\n// after\nawait separateVideoLayers({ src, outputs: { base: { outputWritable: new WritableStream() }, foreground: { outputWritable: new WritableStream() } } });","handlingStrategy":"validation","validationCode":"if (outputs?.base?.outputWritable && outputs.base.outputWritable === outputs?.foreground?.outputWritable) throw new TypeError('base and foreground need distinct WritableStreams');","typeGuard":null,"tryCatchPattern":"try { await separateVideoLayers({ src, outputs }); } catch (e) { if (e instanceof TypeError && e.message.includes('same outputWritable')) { /* create a second stream */ } else throw e; }","preventionTips":["Instantiate one stream per layer","Never share stream references when building options programmatically"],"tags":["validation","conflicting-options","writable-stream"],"backgroundTag":"conflicting-config-options","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}