remotion-dev/remotion · error · Error

No video section defined

Error message

No video section defined

What it means

Thrown at the start of parseMdatSection(). getCurrentMediaSection() returned null for the current iterator offset, i.e. the parser reached the sample-reading phase but no mdat (media data) box has been registered covering the current byte offset. The parser cannot locate the sample data region, so it aborts.

Source

Thrown at packages/media-parser/src/containers/iso-base-media/mdat/mdat.ts:33

import {
	maySkipOverSamplesInTheMiddle,
	maySkipVideoData,
} from '../../../state/may-skip-video-data';
import type {ParserState} from '../../../state/parser-state';
import {getCurrentMediaSection} from '../../../state/video-section';
import {WEBCODECS_TIMESCALE} from '../../../webcodecs-timescale';
import {getMoovAtom} from '../get-moov-atom';
import {postprocessBytes} from './postprocess-bytes';

export const parseMdatSection = async (
	state: ParserState,
): Promise<Skip | FetchMoreData | null> => {
	const mediaSection = getCurrentMediaSection({
		offset: state.iterator.counter.getOffset(),
		mediaSections: state.mediaSection.getMediaSections(),
	});
	if (!mediaSection) {
		throw new Error('No video section defined');
	}

	const endOfMdat = mediaSection.size + mediaSection.start;

	// don't need mdat at all, can skip
	if (maySkipVideoData({state})) {
		const mfra = state.iso.mfra.getIfAlreadyLoaded();

		if (mfra) {
			const lastMoof = getLastMoofBox(mfra);
			if (lastMoof && lastMoof > endOfMdat) {
				Log.verbose(state.logLevel, 'Skipping to last moof', lastMoof);
				return makeSkip(lastMoof);
			}
		}

		return makeSkip(endOfMdat);
	}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Confirm the file actually contains sample data with ffprobe <file> (duration > 0 and streams present).
  2. Re-mux the file to ensure a proper mdat: ffmpeg -i in.mp4 -c copy out.mp4.
  3. If parsing a fragmented MP4 stream/segment, ensure you feed a complete init+media segment, not just the moov.
  4. Avoid manual seeking past known media sections; if using a controller/seekingHints, keep seeks inside the file's media range.

Example fix

// before
await parseMedia({src: maybeMoovOnlyMp4, reader: nodeReader, onVideoTrack: () => {}});

// after
try {
  await parseMedia({src: maybeMoovOnlyMp4, reader: nodeReader, onVideoTrack: () => {}});
} catch (err) {
  if (err instanceof Error && /No video section defined/.test(err.message)) {
    console.warn('File has no mdat/sample data region; nothing to decode');
  } else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the file actually contains sample data (duration > 0) before parsing:
//   ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 in.mp4
import {execFileSync} from 'node:child_process';
function hasMediaData(file: string): boolean {
  try {
    const out = execFileSync('ffprobe',
      ['-v','error','-show_entries','format=duration','-of','default=nw=1:nk=1', file],
      {encoding: 'utf8'});
    const d = Number(out.trim());
    return Number.isFinite(d) && d > 0;
  } catch { return false; }
}

Type guard

// src is a URL/File/Uint8Array; media-section presence is internal parser
// state, not something the caller can narrow on.
// => typeGuard: null

Try / catch

try {
  await parseMedia({src, reader: nodeReader, onVideoTrack: () => {}});
} catch (err) {
  if (err instanceof Error && /No video section defined/.test(err.message)) {
    // no mdat/sample-data region: nothing to decode
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: parseMedia({src}) when the ISO structure lacks a registered mdat section at the read offset: e.g. a moov-only file with no mdat, a truncated/fragmented MP4 whose mdat boundaries were not added via mediaSectionState.addMediaSection(), or a stream where the mdat header was never observed (process-box.ts only registers an mdat when it reads the 'mdat' box type at lines 126-138).

Common situations: Moov-only or metadata-only MP4 files; fragmented MP4 segments missing the mdat wrapper; truncated downloads where the mdat header parsed but the data region math is off; seek scenarios into regions outside any known media section.

Related errors


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