{"record":{"id":"b61980c6c0a84838","repo":"remotion-dev/remotion","slug":"expected-codec-segment","errorCode":null,"errorMessage":"Expected codec segment","messagePattern":"Expected codec segment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/make-track.ts","lineNumber":141,"sourceCode":"\n\t\tif (!priv) {\n\t\t\tthrow new Error('Expected private data in AV1 track');\n\t\t}\n\n\t\treturn parseAv1PrivateData(priv, null);\n\t}\n\n\tthrow new Error(`Unknown codec: ${codec.value}`);\n};\n\nexport const getMatroskaAudioCodecEnum = ({\n\ttrack,\n}: {\n\ttrack: TrackEntry;\n}): MediaParserAudioCodec => {\n\tconst codec = getCodecSegment(track);\n\tif (!codec) {\n\t\tthrow new Error('Expected codec segment');\n\t}\n\n\tif (codec.value === 'A_OPUS') {\n\t\treturn 'opus';\n\t}\n\n\tif (codec.value === 'A_VORBIS') {\n\t\treturn 'vorbis';\n\t}\n\n\tif (codec.value === 'A_PCM/INT/LIT') {\n\t\t// https://github.com/ietf-wg-cellar/matroska-specification/issues/142#issuecomment-330004950\n\t\t// Audio samples MUST be considered as signed values, except if the audio bit depth is 8 which MUST be interpreted as unsigned values.\n\n\t\tconst bitDepth = getBitDepth(track);\n\t\tif (bitDepth === null) {\n\t\t\tthrow new Error('Expected bit depth');\n\t\t}","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/make-track.ts#L123-L159","documentation":"Thrown by `getMatroskaAudioCodecEnum` (make-track.ts:141) when `getCodecSegment(track)` returns null — the audio TrackEntry has no `CodecID` child element. CodecID is mandatory for every Matroska track, so its absence is a spec violation that prevents mapping to an internal codec enum.","triggerScenarios":"Resolving an audio track whose TrackEntry lacks a `CodecID` element. Caused by malformed/truncated EBML, a parser mis-segmentation, or files emitted by a non-conformant muxer.","commonSituations":"Truncated .webm/.mkv where the TrackEntry was cut off before CodecID; corrupt headers; rarely, deliberately minimal test vectors. Most real muxers always emit CodecID.","solutions":["Re-mux or re-encode the file: `ffmpeg -i in.webm -c copy out.webm` (ffmpeg repairs missing elements where possible).","Verify integrity with `ffprobe`; if ffprobe also fails, the file is corrupt.","Catch and treat as unparseable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the file is well-formed with ffprobe before parseMedia.\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nconst exec = promisify(execFile);\nasync function isWellFormed(filePath) {\n  try {\n    await exec('ffprobe', ['-v', 'error', filePath]);\n    return true;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({ src, fields: { tracks: true } });\n} catch (err) {\n  if (err instanceof Error && err.message === 'Expected codec segment') {\n    console.warn('Audio TrackEntry missing CodecID — file is malformed:', src);\n    return null;\n  }\n  throw err;\n}","preventionTips":["Run ffprobe as a pre-flight check for untrusted media.","Re-mux with ffmpeg to repair missing EBML elements.","Reject corrupt assets at upload time rather than during parsing."],"tags":["media-parser","webm","matroska","malformed-input","audio-codec","codecid"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}