{"record":{"id":"c635890a07a49e42","repo":"remotion-dev/remotion","slug":"invalid-sync-code","errorCode":null,"errorMessage":"Invalid sync code","messagePattern":"Invalid sync code","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/flac/parse-flac-frame.ts","lineNumber":165,"sourceCode":"\titerator.destroy();\n};\n\nexport const parseFlacFrame = async ({\n\tstate,\n\titerator,\n}: {\n\tstate: ParserState;\n\titerator: BufferIterator;\n}): Promise<ParseResult> => {\n\tconst blockingBit = state.flac.getBlockingBitStrategy();\n\tconst offset = iterator.counter.getOffset();\n\tconst {returnToCheckpoint} = iterator.startCheckpoint();\n\titerator.startReadingBits();\n\n\tif (blockingBit === undefined) {\n\t\tconst bits = iterator.getBits(15);\n\t\tif (bits !== 0b111111111111100) {\n\t\t\tthrow new Error('Invalid sync code');\n\t\t}\n\n\t\tstate.flac.setBlockingBitStrategy(iterator.getBits(1));\n\t} else if (blockingBit === 1) {\n\t\tconst bits = iterator.getBits(16);\n\t\tif (bits !== 0b1111111111111001) {\n\t\t\tthrow new Error('Blocking bit changed, it should not');\n\t\t}\n\t} else if (blockingBit === 0) {\n\t\tconst bits = iterator.getBits(16);\n\t\tif (bits !== 0b1111111111111000) {\n\t\t\tthrow new Error('Blocking bit changed, it should not');\n\t\t}\n\t}\n\n\tconst setBlockingBit = state.flac.getBlockingBitStrategy();\n\tif (setBlockingBit === undefined) {\n\t\tthrow new Error('Blocking bit should be set');","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/flac/parse-flac-frame.ts#L147-L183","documentation":"Thrown by parseFlacFrame() when parsing the first FLAC frame (blockingBit strategy undefined) and the initial 15 bits do not equal the FLAC sync code 0b111111111111100 (0xFFF8 shifted). Per RFC 9639, every FLAC frame must begin with this 14-bit sync code (0b11111111111110) followed by a reserved bit. If the bits don't match, the data at the current position is not a valid FLAC frame header.","triggerScenarios":"The parser's read position lands on bytes whose first 15 bits are not the FLAC sync pattern. This happens with corrupt frame data, a misaligned read position (e.g. after skipping padding or encountering non-frame data), or a file that is not actually FLAC but was detected as such.","commonSituations":"Corrupt FLAC files with damaged frame headers. Files with trailing garbage or embedded metadata after the audio data. False-positive FLAC detection where a non-FLAC file has an 'fLaC' marker but incompatible content. Seeking to an offset that is not frame-aligned.","solutions":["Verify the file is valid FLAC: `ffprobe input.flac` or `flac -t 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).","Report the file to the Remotion team if it plays correctly in standard players."],"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 sync code') {\n    console.error('FLAC frame sync code mismatch. File may be corrupt. Verify: flac -t <file>');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate FLAC file integrity with `flac -t` or `ffprobe` before parsing.","Ensure files are fully downloaded and not truncated.","Re-encode corrupt FLAC files from a known-good source.","Migrate to Mediabunny for more robust sync recovery."],"tags":["flac","media-parser","sync-code","frame-parsing","corrupt-file"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}