{"record":{"id":"2e5543a704257452","repo":"remotion-dev/remotion","slug":"invalid-traf-number-size","errorCode":null,"errorMessage":"Invalid traf number size","messagePattern":"Invalid traf number size","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/media-parser/src/containers/iso-base-media/mfra/tfra.ts","lineNumber":39,"sourceCode":"): number => {\n\tconst uintTypeTrafNum = (lengthSizeOfTrafNum + 1) * 8;\n\tif (uintTypeTrafNum === 8) {\n\t\treturn iterator.getUint8();\n\t}\n\n\tif (uintTypeTrafNum === 16) {\n\t\treturn iterator.getUint16();\n\t}\n\n\tif (uintTypeTrafNum === 32) {\n\t\treturn iterator.getUint32();\n\t}\n\n\tif (uintTypeTrafNum === 64) {\n\t\treturn Number(iterator.getUint64());\n\t}\n\n\tthrow new Error('Invalid traf number size');\n};\n\nconst readTrunNumber = (\n\titerator: BufferIterator,\n\tlengthSizeOfTrunNum: number,\n): number => {\n\tconst uintTypeTrunNum = (lengthSizeOfTrunNum + 1) * 8;\n\tif (uintTypeTrunNum === 8) {\n\t\treturn iterator.getUint8();\n\t}\n\n\tif (uintTypeTrunNum === 16) {\n\t\treturn iterator.getUint16();\n\t}\n\n\tif (uintTypeTrunNum === 32) {\n\t\treturn iterator.getUint32();\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/mfra/tfra.ts#L21-L57","documentation":"Thrown in readTrafNumber() while parsing a tfra (track fragment random access) box inside mfra. The 2-bit lengthSizeOfTrafNum field yields a uint width other than {8,16,32,64} bits — i.e. it maps to the unsupported 24-bit or 48-bit widths ((lengthSizeOfTrafNum+1)*8 must be one of those four). The traf number size is therefore invalid and the parser aborts.","triggerScenarios":"parseMedia({src}) on a fragmented MP4 whose mfra/tfra box has a malformed size-encoding byte, or whose tmpByte bit-fields are corrupted. Only relevant for fragmented MP4 files that contain an mfra box (used for optimised seeking).","commonSituations":"Corrupted fragmented MP4 (DASH/CMAF segments with an mfra index); non-compliant packagers writing invalid tfra size fields; bit-level corruption in the tfra header.","solutions":["Re-mux the fragmented stream without an mfra index, or regenerate it: ffmpeg -i in.mp4 -c copy -movflags +faststart out.mp4.","Obtain a fresh copy of the segment if you suspect transfer corruption.","If you do not need seeking, request fields/on* callbacks that let the parser skip video data (maySkipVideoData path) so the mfra is not required.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"exampleFix":"// before\nconst {slowKeyframes} = await parseMedia({src: fragmentedMp4, reader: nodeReader});\n\n// after\ntry {\n  const r = await parseMedia({src: fragmentedMp4, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /Invalid traf number size/.test(err.message)) {\n    // mfra/tfra index corrupt; re-mux to regenerate or drop the index\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Only fragmented MP4 with an mfra box hits this. Validate the segment with:\n//   ffprobe -v warning -show_entries format=tags in.mp4\nimport {execFileSync} from 'node:child_process';\nfunction fragmentLooksIntact(file: string): boolean {\n  try {\n    execFileSync('ffprobe', ['-v','warning','-hide_banner', file], {encoding:'utf8', stdio:'pipe'});\n    return true;\n  } catch { return false; }\n}","typeGuard":"// tfra size-encoding bits are deep binary fields in the mfra index; not caller-type-guardable.\n// => typeGuard: null","tryCatchPattern":"try {\n  await parseMedia({src: fragmentedMp4, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /Invalid traf number size/.test(err.message)) {\n    // mfra/tfra index corrupt; re-mux to regenerate or drop the index\n  } else {\n    throw err;\n  }\n}","preventionTips":["Re-mux fragmented MP4 with ffmpeg to regenerate a valid mfra index.","Request only fields that don't force sample iteration to avoid the mfra path.","Re-fetch segments suspected of corruption.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"tags":["mp4","iso-base-media","media-parser","mfra","tfra","fragmented-mp4","corrupt-file","seeking"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}