{"record":{"id":"101df053919cf4a6","repo":"remotion-dev/remotion","slug":"trimafter-must-be-a-positive-number-instead-got","errorCode":null,"errorMessage":"trimAfter must be a positive number, instead got ${trimAfter}.","messagePattern":"trimAfter must be a positive number, instead got (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-start-from-props.ts","lineNumber":80,"sourceCode":"\t\t\tthrow new TypeError(\n\t\t\t\t`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof trimAfter !== 'undefined') {\n\t\tif (typeof trimAfter !== 'number') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (isNaN(trimAfter)) {\n\t\t\tthrow new TypeError('trimAfter prop can not be NaN.');\n\t\t}\n\n\t\tif (trimAfter <= 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`trimAfter must be a positive number, instead got ${trimAfter}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif ((trimAfter as number) <= (trimBefore as number)) {\n\t\tthrow new TypeError('trimAfter prop must be greater than trimBefore prop.');\n\t}\n};\n\nexport const validateMediaTrimProps = ({\n\tstartFrom,\n\tendAt,\n\ttrimBefore,\n\ttrimAfter,\n}: {\n\tstartFrom: number | undefined;\n\tendAt: number | undefined;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-start-from-props.ts#L62-L98","documentation":"trimAfter specifies the frame at which playback stops, and it must be strictly positive (greater than 0). validateTrimProps rejects zero and negative values because an end frame of 0 or below means the media would never play.","triggerScenarios":"Passing trimAfter={0}, trimAfter={-5}, or a computed expression that evaluates to zero or a negative number.","commonSituations":"Setting trimAfter to 0 by mistake (e.g. defaulting an uninitialized variable to 0); subtracting a margin that drives the end before frame 0; off-by-one when trimAfter is computed from a duration that collapses to 0.","solutions":["Pass a positive frame number: trimAfter={200}.","Clamp the computed value to at least 1: trimAfter={Math.max(1, computed)}.","Verify the duration math that produces trimAfter; ensure the source media is long enough."],"exampleFix":"// before\n<Video src={src} trimAfter={duration - margin} /> // can be <= 0\n// after\n<Video src={src} trimAfter={Math.max(1, duration - margin)} />","handlingStrategy":"validation","validationCode":"if (trimAfter !== undefined && trimAfter <= 0) {\n  throw new Error('trimAfter must be > 0');\n}","typeGuard":"const isValidTrimAfter = (v: unknown): v is number =>\n  typeof v === 'number' && !Number.isNaN(v) && v > 0;","tryCatchPattern":null,"preventionTips":["Clamp computed end frames with Math.max(1, value).","Default unset variables to undefined, not 0, so they are skipped rather than rejected.","Verify source media duration is long enough to support the computed trimAfter."],"tags":["validation","props","trimming","range"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}