{"record":{"id":"62f01845f82373d5","repo":"remotion-dev/remotion","slug":"trimbefore-must-be-greater-than-equal-to-0-instead","errorCode":null,"errorMessage":"trimBefore must be greater than equal to 0 instead got ${trimBefore}.","messagePattern":"trimBefore must be greater than equal to 0 instead got (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-start-from-props.ts","lineNumber":62,"sourceCode":"};\n\nexport const validateTrimProps = (\n\ttrimBefore: number | undefined,\n\ttrimAfter: number | undefined,\n) => {\n\tif (typeof trimBefore !== 'undefined') {\n\t\tif (typeof trimBefore !== 'number') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (isNaN(trimBefore) || trimBefore === Infinity) {\n\t\t\tthrow new TypeError('trimBefore prop can not be NaN or Infinity.');\n\t\t}\n\n\t\tif (trimBefore < 0) {\n\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(","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-start-from-props.ts#L44-L80","documentation":"trimBefore represents a frame offset into the media, so it cannot be negative — there is no frame before 0. validateTrimProps rejects negative numbers to prevent seeking to an invalid position.","triggerScenarios":"Passing trimBefore with a negative value (trimBefore={-10}), or a computed expression that goes negative (e.g. trimBefore={offset - margin} where margin exceeds offset).","commonSituations":"Subtracting a padding constant from a dynamic offset without clamping; sign errors in relative-offset math; passing a value derived from a timestamp that can be negative for early frames.","solutions":["Clamp the value to a minimum of 0: trimBefore={Math.max(0, computed)}.","Fix the sign/logic error in the offset calculation.","If the intent is to delay the media rather than trim it, use a <Sequence> with a positive `from` instead."],"exampleFix":"// before\n<Video src={src} trimBefore={offset - 30} />\n// after\n<Video src={src} trimBefore={Math.max(0, offset - 30)} />","handlingStrategy":"validation","validationCode":"if (trimBefore !== undefined && trimBefore < 0) {\n  throw new Error('trimBefore must be >= 0');\n}","typeGuard":"const isValidTrimBefore = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 0;","tryCatchPattern":null,"preventionTips":["Clamp dynamic offsets with Math.max(0, value) before passing.","Use a <Sequence> with a positive `from` when the intent is to delay, not trim.","Double-check sign conventions in relative-offset math."],"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"}