remotion-dev/remotion · error · Error
Unsupported TRUN version ${version}
Error message
Unsupported TRUN version ${version} What it means
The TRUN (Track Run) box parser only supports versions 0 and 1; any other version byte throws. TRUN v0 and v1 are the spec-standard versions (v1 adds signed composition offsets), so a value of 2+ indicates corruption or cursor desync in the surrounding traf.
Source
Thrown at packages/media-parser/src/containers/iso-base-media/trun.ts:30
type TRunSample = {
sampleDuration: number | null;
sampleSize: number | null;
sampleFlags: number | null;
sampleCompositionTimeOffset: number | null;
};
export const parseTrun = ({
iterator,
offset,
size,
}: {
iterator: BufferIterator;
offset: number;
size: number;
}): TrunBox => {
const version = iterator.getUint8();
if (version !== 0 && version !== 1) {
throw new Error(`Unsupported TRUN version ${version}`);
}
const flags = iterator.getUint24();
const sampleCount = iterator.getUint32();
const dataOffset = flags & 0x01 ? iterator.getInt32() : null;
const firstSampleFlags = flags & 0x04 ? iterator.getUint32() : null;
const samples: TRunSample[] = [];
for (let i = 0; i < sampleCount; i++) {
const sampleDuration = flags & 0x100 ? iterator.getUint32() : null;
const sampleSize = flags & 0x200 ? iterator.getUint32() : null;
const sampleFlags = flags & 0x400 ? iterator.getUint32() : null;
const sampleCompositionTimeOffset =
flags & 0x800
? version === 0
? iterator.getUint32()View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Validate with `mp4box -info input.mp4` or `ffprobe -v error input.mp4`.
- Re-fetch or re-mux: `ffmpeg -i segment.m4s -c copy -f mp4 remuxed.mp4`.
- Inspect earlier thrown errors in the same parse session — a traf-level desync is the likely cause.
- Ensure fMP4 segments are fully downloaded before parsing.
Example fix
// before: traf desync makes trun read version 0x02 ffmpeg -i segment.m4s -c copy remuxed.mp4 // after: trun reads version 0 or 1
Defensive patterns
Strategy: try-catch
Validate before calling
function isValidTrunVersion(v: number): boolean {
return v === 0 || v === 1;
} Type guard
function isSupportedTrunVersion(v: number): v is 0 | 1 {
return v === 0 || v === 1;
} Try / catch
try {
await parseMedia({src, fields: {dimensions: true}});
} catch (err) {
if (err instanceof Error && err.message.startsWith('Unsupported TRUN version')) {
// corrupt trun or upstream traf desync; re-mux or re-fetch segment
} else throw err;
} Prevention
- Re-fetch incomplete DASH/HLS segments before parsing.
- Investigate earlier traf-level parse errors first.
- Use mp4box -info to validate fMP4 structure.
When it happens
Trigger: parseTrun reads a version byte other than 0 or 1 at the start of a trun box. Common when the preceding tfhd or saiz/saio box mis-sized and shifted the cursor.
Common situations: Corrupt fragmented MP4 (DASH/HLS) segments, partial segments, or files from buggy live packagers.
Related errors
- Unexpected data left in TRUN box: ${left}
- Expected stsz box in trak box
- expected 0 bytes ${bytesRemaining}
- expected 0 bytes ${bytesRemaining}
- Expected stco box in trak box
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/98c636a183da7740.
Report an issue: GitHub.