🎥 Make videos programmatically with React
more docs and todo comments
Jonny Burger4f7e4b82cbce
diff --git a/packages/docs/docs/deploylambda.md b/packages/docs/docs/deploylambda.mdindex b6c7aa01ac..fc0027768d 100644--- a/packages/docs/docs/deploylambda.md+++ b/packages/docs/docs/deploylambda.md@@ -2,3 +2,46 @@id: deploylambdatitle: deployLambda()---++Creates an [AWS Lambda](https://aws.amazon.com/lambda/) function in your AWS account that will be able to render a video in the cloud.++Before calling `deployLambda()`, you need to deploy the necessary binaries and obtain the identifier for the Lambda Layer. You can do so by calling [`ensureLambdaBinaries()`](/docs/ensurelambdabinaries).++## Example++```ts+import {deployLambda, ensureLambdaBinaries} from '@remotion/lambda';++// ...++const {layerArn} = await ensureLambdaBinaries('us-east-1');+const {functionName} = await deployLambda({+ layerArn,+ region: 'us-east-1',+ timeoutInSeconds: 120+});+console.log(functionName)+```++## Arguments++An object with the following properties:++### `layerArn`++The [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) of the Lambda Layer that should be used. You can obtain it by calling [`ensureLambdaBinaries()`](/docs/ensurelambdabinaries).++### `region`++The AWS region which you want to deploy the Lambda function too. It must be the same region that your Lambda Layer resides in.++### `timeoutInSeconds`++How long the Lambda function may run before it gets killed. Must be below 900 seconds.+We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.++## Return value++An object with the following values:++- `functionName` (_string_): The name of the function just created.diff --git a/packages/docs/docs/deployproject.md b/packages/docs/docs/deployproject.mdindex 59bbb2bb1d..7353a4a43a 100644--- a/packages/docs/docs/deployproject.md+++ b/packages/docs/docs/deployproject.md@@ -1,4 +1,78 @@---id: deployproject-title: deployProject+title: deployProject()---++Takes a Remotion project, bundles it and uploads it to an S3 bucket. Once uploaded, a Lambda function can render any composition in the Remotion project by specifying the URL.++Note that the Remotion project will be deployed to a subdirectory, not the root of the domain. Therefore you must ensure that if you have specified paths in your Remotion project, they are able to handle this scenario.++Before calling this function, you should create a bucket, see [`getOrCreateBucket()`](/docs/getorcreatebucket).++## Example++```ts+import {deployProject} from '@remotion/lambda';++// ...++const {url} = await deployProject({+ entryPoint: '/Users/jonnyburger/my-remotion-video/src/index.tsx',+ bucketName: 'remotionlambda-c7fsl3d',+ region: 'us-east-1',+ options: {+ onBundleProgress: (progress) => {+ console.log(`Bundle progress: ${progress * 100}%`)+ },+ onUploadProgress: ({totalFiles, filesUploaded, totalSize, sizeUploaded}) => {+ console.log(`Upload progress: Total files ${totalFiles}, Files uploaded ${filesUploaded}, Total size ${totalSize}, Size uploaded ${sizeUploaded}`, )+ }+ }+})+console.log(url);+```++## Arguments++An object with the following properties:++### `entryPoint`++An absolute path pointing to the entry file of your Remotion project. Usually the entry file in your Remotion project is stored at `src/entry.tsx`.++### `bucketName`++The bucket to where the website will be deployed. The bucket must have been created by Remotion Lambda.++### `region`++The AWS region in which the bucket resides.++### `options`++_optional_++An object with the following properties:++#### `onBundleProgress`++_optional_++Callback from Webpack when the bundling has progressed. Passes a number between 0 and 1 to the callback, see example at the top of the page.++#### `onUploadProgress`++_optional_++Callback function that gets called when uploading of the assets has progressed. Passes an object with the following properties to the callback:++- `totalFiles` (_number_): Total number of files in the bundle.+- `filesUploaded` (_number_): Number of files that have been fully uploaded so far.+- `totalSize` (_number_): Total size in bytes of all the files in the bundle.+- `sizeUploaded` (_number_): Amount of bytes uploaded so far.++## Return value++An object with the following values:++- `url` _(string)_: The URL of the website that has been deployed. You can pass in this URL when rendering videos with Remotion Lambda.diff --git a/packages/docs/docs/ensurelambdabinaries.md b/packages/docs/docs/ensurelambdabinaries.mdindex b676f72d86..9fbb0f561a 100644--- a/packages/docs/docs/ensurelambdabinaries.md+++ b/packages/docs/docs/ensurelambdabinaries.md@@ -17,12 +17,6 @@ https://lambda-remotion-binaries-<any-s3-region>.s3.<any-s3-region>.amazonaws.coThis value is hardcoded into the `ensureLambdaBinaries()` function - you only need to call it.-## Arguments--### `region`--The AWS region in which you would like to install the binaries. You have to install the binaries separately for each region that you would like to use Remotion Lambda.-## Example```ts@@ -30,5 +24,18 @@ import {ensureLambdaBinaries} from '@remotion/lambda';// ...-await ensureLambdaBinaries('us-east-1');+const {layerArn} = await ensureLambdaBinaries('us-east-1');+console.log(layerArn)```++## Arguments++### `region`++The AWS region in which you would like to install the binaries. You have to install the binaries separately for each region that you would like to use Remotion Lambda.++## Return value++An object with the following keys:++- `layerArn` _(string)_: The [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) of the layer that has been created, or if one has already existed, the ARN of the existing layer.diff --git a/packages/lambda/src/api/bundle-remotion.ts b/packages/lambda/src/api/bundle-remotion.tsindex 1ebee17561..cdcda85f3a 100644--- a/packages/lambda/src/api/bundle-remotion.ts+++ b/packages/lambda/src/api/bundle-remotion.ts@@ -1,5 +1,6 @@import {bundle} from '@remotion/bundler';+// TODO: not hereexport const BINARY_NAME = 'remotion-lambda';// TODO: Necessary? Nodiff --git a/packages/lambda/src/api/deploy-lambda.ts b/packages/lambda/src/api/deploy-lambda.tsindex 68e6a1c825..7603e76376 100644--- a/packages/lambda/src/api/deploy-lambda.ts+++ b/packages/lambda/src/api/deploy-lambda.ts@@ -12,6 +12,7 @@ export const deployLambda = async (options: {layerArn: string;timeoutInSeconds: number;}) => {+ // TODO: Validate parameters and enforce timeout below 900 seconds.const fnNameRender = RENDER_FN_PREFIX + randomHash();const [renderOut, user] = await Promise.all([bundleLambda('render'),diff --git a/packages/lambda/src/api/deploy-project.ts b/packages/lambda/src/api/deploy-project.tsindex dc89a55c2d..52d0de1517 100644--- a/packages/lambda/src/api/deploy-project.ts+++ b/packages/lambda/src/api/deploy-project.ts@@ -22,6 +22,7 @@ export const deployProject = async ({onUploadProgress?: (upload: UploadDirProgress) => void;};}) => {+ // TODO: Validate bucket name starts with prefixconst subFolder = getSitesKey(randomHash());const bundle = await bundleRemotion({entryFile: entryPoint,@@ -44,11 +45,14 @@ export const deployProject = async ({WebsiteConfiguration: {IndexDocument: {+ // TODO: but it doesn't exist+ // TODO: shouldn't we do this beforeSuffix: `index.html`,},},}))+ // TODO if we decide to keep it, add callback to docs.then(() => options?.onWebsiteActivated?.()),]);