Skip to content

🎥 Make videos programmatically with React

frames per lambda calculator in docs

Jonny Burgerbbc52376bd8f
diff --git a/packages/docs/components/Concurrency.tsx b/packages/docs/components/Concurrency.tsx
new file mode 100644
index 0000000000..8de6016ee5
--- /dev/null
+++ b/packages/docs/components/Concurrency.tsx
@@ -0,0 +1,38 @@
+import React from "react";
+
+import { interpolate } from "remotion";
+
+const bestFramesPerLambdaParam = (frameCount: number) => {
+ // Between 0 and 10 minutes (at 30fps), interpolate the concurrency from 75 to 150
+ const concurrency = interpolate(frameCount, [0, 18000], [75, 150], {
+ extrapolateRight: "clamp",
+ });
+
+ // At least have 20 as a `framesPerLambda` value
+ const framesPerLambda = Math.max(frameCount / concurrency, 20);
+
+ // Evenly distribute: For 21 frames over 2 lambda functions, distribute as 11 + 10 ==> framesPerLambda = 11
+ const lambdasNeeded = Math.ceil(frameCount / framesPerLambda);
+
+ return Math.ceil(frameCount / lambdasNeeded);
+};
+
+export const ConcurrencyCalculator: React.FC = () => {
+ const [state, setState] = React.useState(900);
+ const value = bestFramesPerLambdaParam(state);
+ return (
+ <div>
+ Enter number of frames:{" "}
+ <input
+ type={"number"}
+ placeholder="Number of frames"
+ value={state}
+ onChange={(e) => {
+ setState(parseInt(e.target.value, 10));
+ }}
+ />
+ <br />
+ The default <code>framesPerLambda</code> is {value}
+ </div>
+ );
+};
diff --git a/packages/docs/docs/lambda/concurrency.md b/packages/docs/docs/lambda/concurrency.md
index 3c01faaf47..6c0a75b9d6 100644
--- a/packages/docs/docs/lambda/concurrency.md
+++ b/packages/docs/docs/lambda/concurrency.md
@@ -30,7 +30,7 @@ The code for determining the `framesPerLambda` parameter is:
```tsx twoslash
import { interpolate } from "remotion";
-export const bestFramesPerLambdaParam = (frameCount: number) => {
+const bestFramesPerLambdaParam = (frameCount: number) => {
// Between 0 and 10 minutes (at 30fps), interpolate the concurrency from 75 to 150
const concurrency = interpolate(frameCount, [0, 18000], [75, 150], {
extrapolateRight: "clamp",
@@ -46,6 +46,10 @@ export const bestFramesPerLambdaParam = (frameCount: number) => {
};
```
+import {ConcurrencyCalculator} from '../../components/Concurrency'
+
+<ConcurrencyCalculator/>
+
## Concurrency limits
Ensure that you only set parameter within these limits to ensure the renders don't throw any errors: