{"record":{"id":"c9b3aee4846f2235","repo":"remotion-dev/remotion","slug":"not-a-riff-file","errorCode":null,"errorMessage":"Not a RIFF file","messagePattern":"Not a RIFF file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/riff/parse-riff-header.ts","lineNumber":7,"sourceCode":"import type {ParseResult} from '../../parse-result';\nimport type {ParserState} from '../../state/parser-state';\n\nexport const parseRiffHeader = (state: ParserState): ParseResult => {\n\tconst riff = state.iterator.getByteString(4, false);\n\tif (riff !== 'RIFF') {\n\t\tthrow new Error('Not a RIFF file');\n\t}\n\n\tconst structure = state.structure.getRiffStructure();\n\n\tconst size = state.iterator.getUint32Le();\n\tconst fileType = state.iterator.getByteString(4, false);\n\tif (fileType !== 'WAVE' && fileType !== 'AVI') {\n\t\tthrow new Error(`File type ${fileType} not supported`);\n\t}\n\n\tstructure.boxes.push({type: 'riff-header', fileSize: size, fileType});\n\n\treturn null;\n};\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/riff/parse-riff-header.ts#L1-L22","documentation":"Thrown by parseRiffHeader() when the first 4 bytes of the stream are not the ASCII bytes 'RIFF'. This is the container-format sniff for RIFF (used by WAV and AVI); a mismatch means the data is not a RIFF container, but the parser was dispatched to the RIFF path anyway.","triggerScenarios":"The parser's container detection routed a non-RIFF file to parseRiffHeader, or the file is genuinely not WAV/AVI. Also fires on truncated/empty input where fewer than 4 bytes are available (the byte-string read returns something other than 'RIFF').","commonSituations":"Wrong file extension (e.g. .wav on an MP3); corrupt or empty file; misconfigured container detection that preferred RIFF over the real format.","solutions":["Verify the file is actually a RIFF container: check the first 4 bytes equal 0x52 0x49 0x46 0x46 ('RIFF') before parsing, or run ffmpeg -i to inspect.","If the file is a different format, route it through the correct parser (MP4/MOV/MP3/WebM) or let parseMediaStream auto-detect.","Re-export the asset from its source as a real WAV/AVI if it is supposed to be RIFF."],"exampleFix":"// before\nawait parseMediaStream({src: maybeWavUrl, ...});\n\n// after\nconst head = new Uint8Array(await (await fetch(maybeWavUrl, {headers: {Range: 'bytes=0-3'}})).arrayBuffer());\nconst isRiff = head[0] === 0x52 && head[1] === 0x49 && head[2] === 0x46 && head[3] === 0x46;\nif (!isRiff) throw new Error('Not a WAV/AVI');","handlingStrategy":"validation","validationCode":"// Sniff the first 4 bytes for 'RIFF' before parsing.\nconst head = new Uint8Array(await (await fetch(url, {headers: {Range: 'bytes=0-3'}})).arrayBuffer());\nconst isRiff = head[0] === 0x52 && head[1] === 0x49 && head[2] === 0x46 && head[3] === 0x46;\nif (!isRiff) throw new Error('Not a RIFF container');","typeGuard":"function isRiffMagic(bytes: Uint8Array): boolean {\n  return bytes.length >= 4 && bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x46;\n}","tryCatchPattern":"try {\n  await parseMediaStream({src: url});\n} catch (err) {\n  if (err instanceof Error && err.message === 'Not a RIFF file') {\n    // route to the correct container parser or auto-detect\n  } else throw err;\n}","preventionTips":["Let parseMediaStream auto-detect the container rather than forcing RIFF.","Verify file extensions match content; a .wav is not always RIFF/WAVE.","Sniff magic bytes before dispatching to a specific container parser."],"tags":["riff","wav","avi","container-detection","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}