{"record":{"id":"c9f5dd43d7173f7e","repo":"remotion-dev/remotion","slug":"invalid-crc","errorCode":null,"errorMessage":"Invalid CRC","messagePattern":"Invalid CRC","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/flac/parse-flac-frame.ts","lineNumber":105,"sourceCode":"};\n\nconst emitSample = async ({\n\tstate,\n\tdata,\n\toffset,\n}: {\n\tstate: ParserState;\n\tdata: Uint8Array;\n\toffset: number;\n}) => {\n\tconst iterator = getArrayBufferIterator({\n\t\tinitialData: data,\n\t\tmaxBytes: data.length,\n\t\tlogLevel: 'error',\n\t});\n\tconst parsed = parseFrameHeader({iterator, state});\n\tif (!parsed) {\n\t\tthrow new Error('Invalid CRC');\n\t}\n\n\tconst {blockSize, num, sampleRate} = parsed;\n\n\tconst duration = blockSize / sampleRate;\n\tconst structure = state.structure.getFlacStructure();\n\tconst streamInfo = structure.boxes.find(\n\t\t(box) => box.type === 'flac-streaminfo',\n\t);\n\tif (!streamInfo) {\n\t\tthrow new Error('Stream info not found');\n\t}\n\n\tif (streamInfo.minimumBlockSize !== streamInfo.maximumBlockSize) {\n\t\tthrow new Error('Cannot determine timestamp');\n\t}\n\n\tconst timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/flac/parse-flac-frame.ts#L87-L123","documentation":"Thrown by emitSample() during FLAC frame parsing when parseFrameHeader() returns null. parseFrameHeader returns null in two cases: fewer than 10 bytes remain (truncated frame), or the computed CRC-8 of the frame header does not match the stored CRC byte (data corruption or misaligned read). The error message 'Invalid CRC' covers both, though the CRC mismatch is the more common root cause.","triggerScenarios":"Parsing a FLAC frame where either (a) the header has fewer than 10 bytes available, or (b) the CRC-8 computed over the header bytes does not match the CRC byte embedded in the stream. This indicates the frame data is corrupted, the read position is misaligned, or the file is truncated mid-frame.","commonSituations":"Corrupted FLAC files with bit errors in frame headers. Truncated files cut off mid-frame (e.g. incomplete downloads or streams). Files with embedded non-FLAC data that causes the parser to misalign. Aggressive seeking that lands in the middle of a frame without proper sync recovery.","solutions":["Verify file integrity with `flac -t input.flac` or `ffprobe input.flac`.","Re-encode from a known-good source: `ffmpeg -i input.flac output.flac`.","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata) which may have more robust CRC error recovery.","If the file plays in VLC/ffprobe but fails here, report it to the Remotion team."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Invalid CRC') {\n    console.error('FLAC frame CRC mismatch or truncation. Verify: flac -t <file>. Re-encode if corrupt.');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate FLAC files with `flac -t` or `ffprobe` before parsing.","Ensure files are not truncated or corrupted during transfer.","Re-encode corrupt FLAC files from a known-good source.","Migrate to Mediabunny for more robust CRC error recovery."],"tags":["flac","media-parser","crc","corrupt-file","frame-parsing"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}