{"record":{"id":"1f5991b35eba8ab1","repo":"remotion-dev/remotion","slug":"expected-bit-depth","errorCode":null,"errorMessage":"Expected bit depth","messagePattern":"Expected bit depth","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/make-track.ts","lineNumber":158,"sourceCode":"\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}\n\n\t\tif (bitDepth === 8) {\n\t\t\treturn 'pcm-u8';\n\t\t}\n\n\t\tif (bitDepth === 16) {\n\t\t\treturn 'pcm-s16';\n\t\t}\n\n\t\tif (bitDepth === 24) {\n\t\t\treturn 'pcm-s24';\n\t\t}\n\n\t\tthrow new Error('Unknown audio format');\n\t}\n\n\tif (codec.value === 'A_AAC') {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/make-track.ts#L140-L176","documentation":"Thrown by `getMatroskaAudioCodecEnum` (make-track.ts:158) for an `A_PCM/INT/LIT` audio track whose TrackEntry has no `AudioBitDepth` element. Bit depth is mandatory for PCM tracks because the parser must select `pcm-u8` / `pcm-s16` / `pcm-s24`; without it the PCM format is ambiguous.","triggerScenarios":"A PCM (signed little-endian integer) audio track missing the `AudioBitDepth` child element. Occurs with malformed muxers or truncated headers.","commonSituations":"Hand-crafted or corrupted MKV PCM tracks; encoder bugs that omit `AudioBitDepth`; rare in production since PCM is uncommon in WebM.","solutions":["Re-encode the audio to a self-describing codec: `ffmpeg -i in.mkv -c:a pcm_s16le out.mkv` (ensures bit depth is set).","Prefer a non-PCM container (WAV/FLAC) for raw PCM where bit depth is always explicit.","Verify with `ffprobe` and reject malformed assets."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject PCM tracks whose bit depth is unknown — probe with ffprobe.\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nconst exec = promisify(execFile);\nasync function pcmBitDepth(filePath) {\n  const { stdout } = await exec('ffprobe', ['-v', 'error', '-select_entries', 'stream=codec_name,bits_per_sample', '-of', 'json', filePath]);\n  const info = JSON.parse(stdout);\n  const pcm = info.streams?.find((s) => /pcm/i.test(s.codec_name ?? ''));\n  return pcm?.bits_per_sample ?? null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({ src, fields: { tracks: true } });\n} catch (err) {\n  if (err instanceof Error && err.message === 'Expected bit depth') {\n    console.warn('PCM track missing AudioBitDepth — re-encode the file.');\n  }\n  throw err;\n}","preventionTips":["Re-encode PCM tracks with explicit bit depth (pcm_s16le/pcm_s24le) via ffmpeg.","Prefer WAV/FLAC containers for raw PCM where bit depth is implicit and always set.","Probe PCM assets with ffprobe before parsing."],"tags":["media-parser","webm","pcm","audio-codec","malformed-input"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}