{"record":{"id":"44958c46b4ee62d1","repo":"remotion-dev/remotion","slug":"invalid-trun-number-size","errorCode":null,"errorMessage":"Invalid trun number size","messagePattern":"Invalid trun number size","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/media-parser/src/containers/iso-base-media/mfra/tfra.ts","lineNumber":63,"sourceCode":"): 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}\n\n\tif (uintTypeTrunNum === 64) {\n\t\treturn Number(iterator.getUint64());\n\t}\n\n\tthrow new Error('Invalid trun number size');\n};\n\nconst readSampleNumber = (\n\titerator: BufferIterator,\n\tlengthSizeOfSampleNum: number,\n): number => {\n\tconst uintTypeSampleNum = (lengthSizeOfSampleNum + 1) * 8;\n\tif (uintTypeSampleNum === 8) {\n\t\treturn iterator.getUint8();\n\t}\n\n\tif (uintTypeSampleNum === 16) {\n\t\treturn iterator.getUint16();\n\t}\n\n\tif (uintTypeSampleNum === 32) {\n\t\treturn iterator.getUint32();\n\t}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/mfra/tfra.ts#L45-L81","documentation":"Thrown in readTrunNumber() while parsing a tfra box. Same mechanism as the traf-number check: the 2-bit lengthSizeOfTrunNum field maps to a uint width other than {8,16,32,64} (i.e. 24- or 48-bit), which is not supported, so the trun number size is invalid and parsing aborts.","triggerScenarios":"parseMedia({src}) on a fragmented MP4 whose tfra box has a corrupt trun-number size field in its size-encoding byte. Only encountered when an mfra box is present (fragmented MP4 seeking index).","commonSituations":"Corrupted CMAF/DASH fragmented MP4 segments with an mfra index; malformed packager output; bit corruption in the tfra size byte.","solutions":["Re-mux the fragmented file: ffmpeg -i in.mp4 -c copy -movflags +faststart out.mp4.","Re-fetch a clean copy of the segment.","Avoid the mfra path by requesting only metadata/fields that do not force full sample iteration.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"exampleFix":"// before\nawait parseMedia({src: fragmentedMp4, reader: nodeReader});\n\n// after\ntry {\n  await parseMedia({src: fragmentedMp4, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /Invalid trun number size/.test(err.message)) {\n    // tfra trun-number size corrupt; re-mux the fragmented file\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Validate the fragmented segment before parsing:\n//   ffprobe -v warning 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 trun-number size bits are deep binary fields; 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 trun number size/.test(err.message)) {\n    // tfra trun-number size corrupt; re-mux the fragmented file\n  } else {\n    throw err;\n  }\n}","preventionTips":["Re-mux fragmented MP4 with ffmpeg to rebuild a valid mfra index.","Avoid forcing the mfra/seeking path by limiting requested fields.","Re-fetch clean copies of corrupted segments.","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-12T18:17:37.767Z"}