{"record":{"id":"96df9db1f83f2e91","repo":"remotion-dev/remotion","slug":"expected-1","errorCode":null,"errorMessage":"Expected 1","messagePattern":"Expected 1","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/mp3/parse-packet-header.ts","lineNumber":177,"sourceCode":"\t};\n\n\t// Determine the correct key based on version and level\n\tlet key: string;\n\tif (mpegVersion === 2 && (level === 2 || level === 3)) {\n\t\tkey = 'V2,L2&L3';\n\t} else {\n\t\tkey = `V${mpegVersion},L${level}`;\n\t}\n\n\t// Return the corresponding bitrate\n\treturn bitrateTable[bits][key];\n}\n\nconst innerParseMp3PacketHeader = (iterator: BufferIterator) => {\n\tfor (let i = 0; i < 11; i++) {\n\t\tconst expectToBe1 = iterator.getBits(1);\n\t\tif (expectToBe1 !== 1) {\n\t\t\tthrow new Error('Expected 1');\n\t\t}\n\t}\n\n\tconst audioVersionId = iterator.getBits(2);\n\t/**\n   * 00 - MPEG Version 2.5 (later extension of MPEG 2)\n     01 - reserved\n     10 - MPEG Version 2 (ISO/IEC 13818-3)\n     11 - MPEG Version 1 (ISO/IEC 11172-3)\n   */\n\tif (\n\t\taudioVersionId !== 0b11 &&\n\t\taudioVersionId !== 0b10 &&\n\t\taudioVersionId !== 0b00\n\t) {\n\t\tthrow new Error('Expected MPEG Version 1 or 2');\n\t}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/mp3/parse-packet-header.ts#L159-L195","documentation":"Thrown by `innerParseMp3PacketHeader` during the MPEG frame sync check. An MPEG audio frame begins with 11 consecutive set bits (the sync word). The parser reads 11 individual 1-bit fields and if any bit is not `1`, the data is not aligned on a valid MPEG frame sync and the parser refuses to continue.","triggerScenarios":"During frame header parsing (`parse-packet-header.ts:174-179`), one of the first 11 bits read from the byte stream is `0` instead of `1`. This means the iterator is not positioned at a valid MPEG frame sync word.","commonSituations":"Corrupt or non-MP3 data being interpreted as an MPEG frame. Misaligned byte offset after a previous frame-length miscalculation. Files with junk/padding between frames. The parser was pointed at random data. Truncated files where the bit reader hits garbage.","solutions":["Validate the file is a genuine MP3 with `ffprobe -i file.mp3`.","Re-encode the file from a known-good source to eliminate corruption.","Check for partial downloads or incomplete file transfers.","If this occurs on a specific file, report it at remotion.dev/report."],"exampleFix":"# validate MP3 integrity\nffprobe -v error -i input.mp3\n\n# re-encode\nffmpeg -i input.mp3 -codec:a libmp3lame -b:a 192k output.mp3","handlingStrategy":"try-catch","validationCode":"// Verify MPEG frame sync word (11 set bits = 0xFFE0 in first two bytes)\nasync function hasValidSyncWord(file: File): Promise<boolean> {\n  // Skip past ID3v2 header if present\n  const buf = await file.slice(0, 4096).arrayBuffer();\n  const bytes = new Uint8Array(buf);\n  for (let i = 0; i < bytes.length - 1; i++) {\n    if ((bytes[i] & 0xff) === 0xff && (bytes[i + 1] & 0xe0) === 0xe0) {\n      return true; // found valid sync word\n    }\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Expected 1') {\n    console.error('No valid MPEG frame sync word found. The MP3 data may be corrupt.');\n  }\n  throw e;\n}","preventionTips":["Verify the MP3 file has valid frame sync words (0xFF followed by 0xE0+).","Re-encode corrupt MP3 files from a known-good source.","Check for partial downloads or byte-level corruption.","Use ffprobe to validate file integrity before parsing."],"tags":["mp3","corrupt-file","frame-sync","invalid-header","byte-alignment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}