remotion-dev/remotion · error · Error
Expected width segment
Error message
Expected width segment
What it means
Thrown by `getTrack` (make-track.ts:282) for a video track whose TrackEntry has no `PixelWidth` element (`getWidthSegment` returns null). PixelWidth is mandatory for video tracks in Matroska; without it the coded/display width is unknown and the track object cannot be constructed.
Source
Thrown at packages/media-parser/src/containers/webm/make-track.ts:282
timescale,
track,
}: {
timescale: number;
track: TrackEntry;
}): MediaParserVideoTrack | MediaParserAudioTrack | null => {
const trackType = getTrackTypeSegment(track);
if (!trackType) {
throw new Error('Expected track type segment');
}
const trackId = getTrackId(track);
if (trackTypeToString(trackType.value.value) === 'video') {
const width = getWidthSegment(track);
if (width === null) {
throw new Error('Expected width segment');
}
const height = getHeightSegment(track);
if (height === null) {
throw new Error('Expected height segment');
}
const displayHeight = getDisplayHeightSegment(track);
const displayWidth = getDisplayWidthSegment(track);
const codec = getCodecSegment(track);
if (!codec) {
return null;
}
const codecPrivate = getPrivateData(track);
const codecString = getMatroskaVideoCodecString({View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Re-mux/re-encode so dimensions are recorded: `ffmpeg -i in.webm -c copy out.webm`.
- Verify with `ffprobe` — missing PixelWidth typically breaks it too.
- Reject the corrupt asset upstream; catch the parse error and degrade.
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the video stream reports dimensions before parsing.
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const exec = promisify(execFile);
async function hasDimensions(filePath) {
const { stdout } = await exec('ffprobe', ['-v', 'error', '-select_entries', 'stream=width,height', '-of', 'json', filePath]);
const info = JSON.parse(stdout);
return info.streams?.some((s) => s.width && s.height) ?? false;
} Try / catch
try {
await parseMedia({ src, fields: { tracks: true } });
} catch (err) {
if (err instanceof Error && err.message === 'Expected width segment') {
console.warn('Video TrackEntry missing PixelWidth — malformed file:', src);
return null;
}
throw err;
} Prevention
- Probe video dimensions with ffprobe before parsing to catch malformed headers.
- Re-mux/re-encode corrupt files so PixelWidth and PixelHeight are written.
- Reject malformed assets upstream.
When it happens
Trigger: A video TrackEntry missing `PixelWidth`. Truncated/corrupt headers, non-conformant muxers, or files where the video element block was written before dimensions were finalized.
Common situations: Interrupted encodes; corrupt MKV/WebM video track headers; rare muxer bugs. Files that play elsewhere virtually always carry PixelWidth.
Related errors
- Expected height segment
- Expected track entry segment
- Expected codec segment
- Expected track type segment
- Expected av1 private data to be version 1
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/a1fb6c027c88e466.
Report an issue: GitHub.