remotion-dev/remotion · error · Error

Could not find codec for track ${trackNumber}

Error message

Could not find codec for track ${trackNumber}

What it means

Thrown at get-sample-from-block.ts:168 when `webmState.getTrackInfoByNumber(trackNumber)` returns an object with an empty/falsy `codec`. The track number encoded in the block does not map to a registered codec string, meaning the block references an unknown or not-yet-parsed track.

Source

Thrown at packages/media-parser/src/containers/webm/get-sample-from-block.ts:168

	const timescale = webmState.getTimescale();

	if (clusterOffset === undefined) {
		throw new Error('Could not find offset for byte offset ' + offset);
	}

	// https://github.com/hubblec4/Matroska-Chapters-Specs/blob/master/notes.md/#timestampscale
	// The TimestampScale Element is used to calculate the Raw Timestamp of a Block. The timestamp is obtained by adding the Block's timestamp to the Cluster's Timestamp Element, and then multiplying that result by the TimestampScale. The result will be the Block's Raw Timestamp in nanoseconds.
	const timecodeInNanoSeconds =
		(timecodeRelativeToCluster + clusterOffset) *
		timescale *
		(trackTimescale ?? 1);

	// Timecode should be in microseconds
	const timecodeInMicroseconds = timecodeInNanoSeconds / 1000;

	if (!codec) {
		throw new Error(`Could not find codec for track ${trackNumber}`);
	}

	const remainingNow = ebml.value.length - iterator.counter.getOffset();

	if (codec.startsWith('V_')) {
		const partialVideoSample: Omit<MediaParserVideoSample, 'type'> = {
			data: iterator.getSlice(remainingNow),
			decodingTimestamp: timecodeInMicroseconds,
			duration: undefined,
			timestamp: timecodeInMicroseconds,
			offset,
		};

		if (keyframe === null) {
			iterator.destroy();

			return {
				type: 'partial-video-sample',

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Confirm the file's tracks with `ffprobe` — if it contains non-A/V tracks, that is expected; the error indicates those blocks should be filtered earlier.
  2. For AVC-in-WebM without CodecPrivate, ensure the first keyframe (with SPS) is processed before later blocks; avoid skipping it via controller seeks.
  3. Re-mux to strip problematic tracks: `ffmpeg -i in.webm -c copy -map 0:v:0 -map 0:a:0 out.webm`.
  4. Catch the error and skip the asset.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-list tracks; if a block-only track (e.g. subtitle) exists, expect codec misses.
import { parseMedia } from '@remotion/media-parser';
async function listTracks(src) {
  return parseMedia({ src, fields: { tracks: true } });
}

Try / catch

try {
  await parseMedia({ src, fields: { samples: true } });
} catch (err) {
  if (err instanceof Error && /Could not find codec for track \d+/.test(err.message)) {
    console.warn('Block references an unresolved/unknown track in', src);
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: A Block/SimpleBlock carries a trackNumber that was never registered during the Tracks parsing pass, or whose codec could not be resolved (e.g. a subtitle track, an unsupported codec, or a trackNumber from a different edition). The `getTrackInfoByNumber` lookup succeeds structurally but returns an empty codec.

Common situations: WebM files with subtitle/metadata tracks whose codec the parser ignores; AVC tracks stuck in `missingInfo` whose codec is still empty when a block arrives before profile resolution; files with multiple editions or track-number reuse.

Related errors


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