remotion-dev/remotion · error · Error

Expected 1

Error message

Expected 1

What it means

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.

Source

Thrown at packages/media-parser/src/containers/mp3/parse-packet-header.ts:177

	};

	// Determine the correct key based on version and level
	let key: string;
	if (mpegVersion === 2 && (level === 2 || level === 3)) {
		key = 'V2,L2&L3';
	} else {
		key = `V${mpegVersion},L${level}`;
	}

	// Return the corresponding bitrate
	return bitrateTable[bits][key];
}

const innerParseMp3PacketHeader = (iterator: BufferIterator) => {
	for (let i = 0; i < 11; i++) {
		const expectToBe1 = iterator.getBits(1);
		if (expectToBe1 !== 1) {
			throw new Error('Expected 1');
		}
	}

	const audioVersionId = iterator.getBits(2);
	/**
   * 00 - MPEG Version 2.5 (later extension of MPEG 2)
     01 - reserved
     10 - MPEG Version 2 (ISO/IEC 13818-3)
     11 - MPEG Version 1 (ISO/IEC 11172-3)
   */
	if (
		audioVersionId !== 0b11 &&
		audioVersionId !== 0b10 &&
		audioVersionId !== 0b00
	) {
		throw new Error('Expected MPEG Version 1 or 2');
	}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Validate the file is a genuine MP3 with `ffprobe -i file.mp3`.
  2. Re-encode the file from a known-good source to eliminate corruption.
  3. Check for partial downloads or incomplete file transfers.
  4. If this occurs on a specific file, report it at remotion.dev/report.

Example fix

# validate MP3 integrity
ffprobe -v error -i input.mp3

# re-encode
ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 192k output.mp3
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify MPEG frame sync word (11 set bits = 0xFFE0 in first two bytes)
async function hasValidSyncWord(file: File): Promise<boolean> {
  // Skip past ID3v2 header if present
  const buf = await file.slice(0, 4096).arrayBuffer();
  const bytes = new Uint8Array(buf);
  for (let i = 0; i < bytes.length - 1; i++) {
    if ((bytes[i] & 0xff) === 0xff && (bytes[i + 1] & 0xe0) === 0xe0) {
      return true; // found valid sync word
    }
  }
  return false;
}

Try / catch

try {
  await parseMedia({src, fields: {durationInSeconds: true}});
} catch (e) {
  if (e instanceof Error && e.message === 'Expected 1') {
    console.error('No valid MPEG frame sync word found. The MP3 data may be corrupt.');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/96df9db1f83f2e91. Report an issue: GitHub.