remotion-dev/remotion · error · Error

The primary video track contains no presentable video durati

Error message

The primary video track contains no presentable video duration.

What it means

The library computes the video duration via videoTrack.computeDuration() and a start timestamp via getFirstTimestamp(); if videoEndTimestamp <= videoStartTimestamp (after clamping start to 0), there is no usable playback duration to separate, so it throws. This means the track reports zero, negative, or undefined-length video content.

Source

Thrown at packages/video-matting/src/separate-video-layers.ts:331

		options.audioBitrate ?? 'medium',
	);
	const keyframeIntervalInSeconds = options.keyframeIntervalInSeconds ?? 1;
	const input = makeInput(options.src);
	const onInputAbort = () => input.dispose();
	options.signal?.addEventListener('abort', onInputAbort, {once: true});

	try {
		const {videoTrack, width, height} = await probeVideoInput({
			input,
			videoQuality,
		});
		const [inputFirstVideoTimestamp, videoEndTimestamp] = await Promise.all([
			videoTrack.getFirstTimestamp(),
			videoTrack.computeDuration(),
		]);
		const videoStartTimestamp = Math.max(inputFirstVideoTimestamp, 0);
		if (videoEndTimestamp <= videoStartTimestamp) {
			throw new Error(
				'The primary video track contains no presentable video duration.',
			);
		}

		const durationInSeconds = videoEndTimestamp - videoStartTimestamp;
		throwIfAborted(options.signal);

		const result = await withLoadedVideoMattingPipeline({
			model,
			onProgress: options.onModelLoadProgress,
			signal: options.signal ?? null,
			run: async (pipeline) => {
				throwIfAborted(options.signal);
				let iterator: AsyncGenerator<
					{
						canvas: HTMLCanvasElement | OffscreenCanvas;
						timestamp: number;
						duration: number;

View on GitHub (pinned to b2f4e34732)

Solutions

  1. Verify the file plays and shows a real duration in a player / ffprobe before processing.
  2. Re-encode the source with ffmpeg (this rebuilds duration metadata): ffmpeg -i in.mp4 -c:v libx264 out.mp4.
  3. If the file is a fragmented/live recording, finalize it (e.g. remux with ffmpeg) so the duration is written.
  4. Guard in code: check the media duration > 0 before calling separateVideoLayers.

Example fix

// before
await separateVideoLayers({src: zeroDurationClip.webm});
// after
const duration = await getTrackDuration(zeroDurationClip); // your probe
if (duration <= 0) throw new Error('Source clip has no duration');
await separateVideoLayers({src: zeroDurationClip});
Defensive patterns

Strategy: validation

Validate before calling

const input = new Input({source: new BlobSource(file), formats: ALL_FORMATS});
const track = await input.getPrimaryVideoTrack();
const duration = await track.computeDuration();
if (duration <= 0) throw new Error('Source video has no usable duration');

Prevention

When it happens

Trigger: Input container whose video track has zero-length or corrupt duration metadata (e.g. moov missing duration), a first timestamp larger than the computed end timestamp, or a recording stopped immediately after starting (0 frames of duration).

Common situations: Files recorded and aborted instantly; broken muxers writing duration 0; live-recorded fragments where timestamps start above the computed duration; corrupted mp4 whose duration field was never finalized.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09). Data as JSON: /api/errors/4381dbccec759e54. Report an issue: GitHub.