{"record":{"id":"b14ba309837ee172","repo":"remotion-dev/remotion","slug":"cannot-use-frame-frame-duration-of-composition-b14ba3","errorCode":null,"errorMessage":"Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${durationInFrames - 1}","messagePattern":"Cannot use frame (.+?): Duration of composition is (.+?), therefore the highest frame that can be rendered is (.+?)","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-frame.ts","lineNumber":37,"sourceCode":"\n\tif (!Number.isFinite(frame)) {\n\t\tthrow new RangeError(`Frame ${frame} is not finite`);\n\t}\n\n\tif (frame % 1 !== 0 && !allowFloats) {\n\t\tthrow new RangeError(\n\t\t\t`Argument for frame must be an integer, but got ${frame}`,\n\t\t);\n\t}\n\n\tif (frame < 0 && frame < -durationInFrames) {\n\t\tthrow new RangeError(\n\t\t\t`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the lowest frame that can be rendered is ${-durationInFrames}`,\n\t\t);\n\t}\n\n\tif (frame > durationInFrames - 1) {\n\t\tthrow new RangeError(\n\t\t\t`Cannot use frame ${frame}: Duration of composition is ${durationInFrames}, therefore the highest frame that can be rendered is ${\n\t\t\t\tdurationInFrames - 1\n\t\t\t}`,\n\t\t);\n\t}\n};\n","sourceCodeStart":19,"sourceCodeEnd":44,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-frame.ts#L19-L44","documentation":"validateFrame throws a RangeError when frame exceeds durationInFrames - 1 (the last valid frame). This is the upper-bound counterpart to 374. The message reports the highest allowed frame. It guards rendering and seeking against out-of-range positive frames.","triggerScenarios":"Seeking past the end of the composition; computing frame from a time value beyond duration; off-by-one in loop math; passing absolute frame when a relative frame was expected.","commonSituations":"Looping logic that increments frame past the end; interpolation/extrapolation that overshoots; user scrubbing beyond duration; mismatched durationInFrames between caller and composition.","solutions":["Clamp to the last frame: `Math.min(frame, durationInFrames - 1)`.","Verify the durationInFrames used in the call matches the composition's actual duration.","Use modulo for loops: `frame % durationInFrames`.","Validate user seek input against duration before calling."],"exampleFix":"// before\nseekTo(targetFrame); // targetFrame > durationInFrames - 1\n\n// after\nconst safeFrame = Math.min(targetFrame, durationInFrames - 1);\nseekTo(safeFrame);","handlingStrategy":"validation","validationCode":"const safeFrame = Math.min(frame, durationInFrames - 1);\nvalidateFrame({ frame: safeFrame, durationInFrames, allowFloats });","typeGuard":"const isBelowUpperBound = (f: number, dur: number) => f <= dur - 1;","tryCatchPattern":null,"preventionTips":["Clamp seeks to durationInFrames - 1.","Use modulo for loops: frame % durationInFrames.","Confirm the duration used at the call site matches the composition's duration."],"tags":["remotion","frame","validation","rangeerror","bounds","off-by-one"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}