remotion-dev/remotion · error · Error

Could not find video codec

Error message

Could not find video codec

What it means

Thrown by makeBaseMediaTrack() after dimensions are resolved. getVideoCodecString(trakBox) returned a falsy value, meaning the video FourCC in stsd is not mapped to a known WebCodecs codec string (e.g. avc1/hev1/vp08/av01). Since the codec string is needed to configure a VideoDecoder, the parser aborts.

Source

Thrown at packages/media-parser/src/containers/iso-base-media/make-track.ts:140

	const sampleAspectRatio = getSampleAspectRatio(trakBox);

	const aspectRatioApplied = applyAspectRatios({
		dimensions: videoSample,
		sampleAspectRatio,
		displayAspectRatio: getDisplayAspectRatio({
			sampleAspectRatio,
			nativeDimensions: videoSample,
		}),
	});

	const {displayAspectHeight, displayAspectWidth, height, rotation, width} =
		applyTkhdBox(aspectRatioApplied, tkhdBox);

	const codec = getVideoCodecString(trakBox);

	if (!codec) {
		throw new Error('Could not find video codec');
	}

	const privateData = getVideoPrivateData(trakBox);

	const advancedColor = getIsoBmColrConfig(trakBox) ?? {
		fullRange: null,
		matrix: null,
		primaries: null,
		transfer: null,
	};

	const track: MediaParserVideoTrack = {
		m3uStreamFormat: null,
		type: 'video',
		trackId: tkhdBox.trackId,
		description: videoDescriptors ?? undefined,
		originalTimescale: timescaleAndDuration.timescale,
		codec,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Transcode the video to a WebCodecs-supported codec: ffmpeg -i in.mp4 -c:v libx264 -crf 20 -pix_fmt yuv420p out.mp4 (H.264) or libvpx-vp9/libaom-av1.
  2. Update @remotion/media-parser (or move to @remotion/mediabunny) — newer versions add codec mappings.
  3. Run ffprobe <file> to identify the FourCC and confirm it is one WebCodecs supports.
  4. If the codec is supported but the config box is missing, re-mux with ffmpeg -i in.mp4 -c:v copy out.mp4 to rebuild boxes.

Example fix

// before
const {videoCodec} = await parseMedia({src, reader: nodeReader});

// after
let videoCodec: string | null = null;
try {
  ({videoCodec} = await parseMedia({src, reader: nodeReader}));
} catch (err) {
  if (err instanceof Error && /Could not find video codec/.test(err.message)) {
    console.warn('Unrecognised video FourCC; transcode to H.264 with ffmpeg');
    videoCodec = null;
  } else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the video codec/FourCC is one WebCodecs supports before parsing:
//   ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nw=1:nk=1 in.mp4
import {execFileSync} from 'node:child_process';
const SUPPORTED = new Set(['h264','hevc','vp8','vp9','av1']);
function videoCodecSupported(file: string): boolean {
  try {
    const codec = execFileSync('ffprobe',
      ['-v','error','-select_streams','v:0','-show_entries','stream=codec_name','-of','default=nw=1:nk=1', file],
      {encoding: 'utf8'}).trim();
    return SUPPORTED.has(codec);
  } catch { return false; }
}

Type guard

// No structural guard: codec recognition happens deep inside the parser.
// => typeGuard: null

Try / catch

let videoCodec: string | null = null;
try {
  ({videoCodec} = await parseMedia({src, reader: nodeReader}));
} catch (err) {
  if (err instanceof Error && /Could not find video codec/.test(err.message)) {
    videoCodec = null; // unsupported/unrecognised FourCC
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: parseMedia({src}) on a video MP4/MOV whose stsd sample entry uses a FourCC the parser does not recognise or map, or where the stsd/codec-resolution code path returns null for another reason (e.g. missing avcC/hvcC/vpcC/av1C config box under a recognised FourCC).

Common situations: Files using rare or proprietary codecs (e.g. certain ProRes/DivX/Xvid/Cinepack-in-MP4 variants), newly added codecs the parser version predates, or files whose codec config sub-boxes were stripped.

Related errors


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