{"record":{"id":"8414a86fcd5b4ca4","repo":"remotion-dev/remotion","slug":"expected-size-4-for-fact-box-got-size","errorCode":null,"errorMessage":"Expected size 4 for fact box, got ${size}","messagePattern":"Expected size 4 for fact box, got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/wav/parse-fact.ts","lineNumber":13,"sourceCode":"import type {ParseResult} from '../../parse-result';\nimport type {ParserState} from '../../state/parser-state';\nimport type {WavFact} from './types';\n\nexport const parseFact = ({\n\tstate,\n}: {\n\tstate: ParserState;\n}): Promise<ParseResult> => {\n\tconst {iterator} = state;\n\tconst size = iterator.getUint32Le();\n\tif (size !== 4) {\n\t\tthrow new Error(`Expected size 4 for fact box, got ${size}`);\n\t}\n\n\tconst numberOfSamplesPerChannel = iterator.getUint32Le();\n\tconst factBox: WavFact = {\n\t\ttype: 'wav-fact',\n\t\tnumberOfSamplesPerChannel,\n\t};\n\tstate.structure.getWavStructure().boxes.push(factBox);\n\treturn Promise.resolve(null);\n};\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/wav/parse-fact.ts#L1-L24","documentation":"The WAV 'fact' chunk is spec-defined to hold exactly one uint32 (numberOfSamplesPerChannel), i.e. 4 payload bytes. parseFact reads the chunk size and rejects anything other than 4 because the parser only models the canonical fact payload. A non-4 size indicates a malformed, extended, or corrupted fact chunk.","triggerScenarios":"parseMedia() on a WAV whose 'fact' chunk size field is not 4: a padded/extended fact chunk, a corrupted size word, or an encoder that emits a non-standard fact body.","commonSituations":"Non-compliant encoders; broadcast/DAW WAVs with extended fact data; hand-edited or partially-overwritten files; files passed through lossy conversion.","solutions":["Inspect the fact chunk size in a hex editor or via ffprobe -show_format.","Re-encode to a clean WAV: ffmpeg -i in.wav out.wav.","Use Mediabunny for broader WAV compatibility.","try/catch parseMedia() and treat the file as unsupported."],"exampleFix":"# re-encode to a spec-clean WAV\nffmpeg -i in.wav -c:a pcm_s16le out.wav\n\n// then handle failure gracefully\ntry { await parseMedia({ src: 'out.wav' }); } catch { /* unsupported */ }","handlingStrategy":"try-catch","validationCode":"// ffprobe check: a spec-clean fact chunk parses without warning\n// ffprobe -v warning in.wav   (exit 0 + no warnings => fact chunk ok)","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({ src: 'in.wav' });\n} catch (err) {\n  if (err instanceof Error && /fact box/i.test(err.message)) {\n    // non-standard fact chunk — re-encode or skip\n  } else throw err;\n}","preventionTips":["Re-encode WAVs from untrusted sources with ffmpeg before parsing.","Use Mediabunny for broader chunk tolerance.","Treat parseMedia() as fallible and always wrap it."],"tags":["wav","media-parser","corrupt-file","audio"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}