{"record":{"id":"f9d08d26ab4b4524","repo":"remotion-dev/remotion","slug":"stream-buffer-not-found","errorCode":null,"errorMessage":"Stream buffer not found","messagePattern":"Stream buffer not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/transport-stream/process-audio.ts","lineNumber":63,"sourceCode":"\ttransportStream,\n\tmakeSamplesStartAtZero,\n\tavcState,\n}: {\n\ttransportStreamEntry: TransportStreamEntry;\n\tstructure: TransportStreamStructure;\n\tsampleCallbacks: CallbacksState;\n\tlogLevel: MediaParserLogLevel;\n\tonAudioTrack: MediaParserOnAudioTrack | null;\n\tonVideoTrack: MediaParserOnVideoTrack | null;\n\ttransportStream: TransportStreamState;\n\toffset: number;\n\tmakeSamplesStartAtZero: boolean;\n\tavcState: AvcState;\n}): Promise<void> => {\n\tconst {streamBuffers, nextPesHeaderStore: nextPesHeader} = transportStream;\n\tconst streamBuffer = streamBuffers.get(transportStreamEntry.pid);\n\tif (!streamBuffer) {\n\t\tthrow new Error('Stream buffer not found');\n\t}\n\n\tconst expectedLength =\n\t\treadAdtsHeader(streamBuffer.getBuffer())?.frameLength ?? null;\n\n\tif (expectedLength === null) {\n\t\tthrow new Error('Expected length is null');\n\t}\n\n\tif (expectedLength > streamBuffer.getBuffer().length) {\n\t\tthrow new Error('Expected length is greater than stream buffer length');\n\t}\n\n\tawait processStreamBuffer({\n\t\tstreamBuffer: makeTransportStreamPacketBuffer({\n\t\t\tbuffers: streamBuffer.getBuffer().slice(0, expectedLength),\n\t\t\toffset,\n\t\t\tpesHeader: streamBuffer.pesHeader,","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/transport-stream/process-audio.ts#L45-L81","documentation":"Thrown by processAudio at process-audio.ts:63 when transportStream.streamBuffers does not contain an entry for transportStreamEntry.pid. This is an internal-state invariant: by the time processAudio is invoked, a buffer for the PID should have been allocated during earlier PES assembly.","triggerScenarios":"processAudio looks up streamBuffers.get(transportStreamEntry.pid) and throws on undefined. Triggered when audio processing is scheduled for a PID before any PES packet for that PID has been buffered, or when the streamBuffers map has been cleared/reset mid-parse.","commonSituations":"Race-condition style bugs in the parser; corrupt streams where the PMT references a PID that never carries packets; partial files where audio packets are missing; an internal ordering bug between PAT/PMT/PES handling.","solutions":["Re-mux the source: ffmpeg -i in.ts -c copy out.ts to ensure every PMT-declared PID has packets.","If reproducing, file a bug on @remotion/media-parser with the sample.","Verify with ffprobe that the audio PID is present and carries data.","Transcode to MP4 as a workaround to skip the transport-stream code path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await parseMedia({src}); }\ncatch (e) {\n  if (e instanceof Error && e.message === 'Stream buffer not found') {\n    // internal state issue - try re-muxing, otherwise report\n    await runFfmpeg(['-i', src, '-c', 'copy', src + '.remux.ts']);\n    await parseMedia({src: src + '.remux.ts'});\n  } else throw e;\n}","preventionTips":["Re-mux .ts files to ensure every PMT-declared PID carries packets.","Verify with ffprobe that declared audio PIDs have data.","Report persistent occurrences to @remotion/media-parser with a sample."],"tags":["media-parser","transport-stream","mpegts","audio","internal-state"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}