🎥 Make videos programmatically with React
renderStillOnCloudrun docs + fixes
Matt McGillivray2bb26aedd4d9
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.tsindex 6b12dd914c..a78b7b0ffe 100644--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts@@ -177,8 +177,8 @@ export const renderMediaOnCloudrun = async ({responseType: 'stream',});- const authenticatedDataPromise =- await new Promise<RenderMediaOnCloudrunOutput>((resolve, reject) => {+ const renderResponse = await new Promise<RenderMediaOnCloudrunOutput>(+ (resolve, reject) => {// TODO: Add any sort of type safetylet response: RenderMediaOnCloudrunOutput | ErrorResponsePayload;@@ -204,7 +204,8 @@ export const renderMediaOnCloudrun = async ({stream.on('error', (error: Error) => {reject(error);});- });+ }+ );- return authenticatedDataPromise;+ return renderResponse;};diff --git a/packages/cloudrun/src/api/render-still-on-cloudrun.ts b/packages/cloudrun/src/api/render-still-on-cloudrun.tsindex a40211a57a..d8fb79430a 100644--- a/packages/cloudrun/src/api/render-still-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-still-on-cloudrun.ts@@ -21,9 +21,9 @@ export type RenderStillOnCloudrunInput = {serveUrl: string;composition: string;inputProps?: unknown;- forceBucketName?: string;privacy?: 'public' | 'private';- outputFile?: string;+ forceBucketName?: string;+ outName?: string;imageFormat: StillImageFormat;envVariables?: Record<string, string>;frame?: number;@@ -46,7 +46,7 @@ export type RenderStillOnCloudrunInput = {* @param params.inputProps The input props that should be passed to the composition.* @param params.forceBucketName The name of the bucket that the output file should be uploaded to.* @param params.privacy Whether the output file should be public or private.- * @param params.outputFile The name of the output file.+ * @param params.outName The name of the output file.* @param params.imageFormat Which image format the frame should be rendered in.* @param params.envVariables Object containing environment variables to be injected in your project.* @param params.frame Which frame of the composition should be rendered. Frames are zero-indexed.@@ -68,7 +68,7 @@ export const renderStillOnCloudrun = async ({inputProps,forceBucketName,privacy,- outputFile,+ outName,imageFormat,envVariables,frame,@@ -96,7 +96,7 @@ export const renderStillOnCloudrun = async ({serveUrl,inputProps,outputBucket,- outputFile,+ outName,privacy,imageFormat,envVariables,@@ -112,10 +112,10 @@ export const renderStillOnCloudrun = async ({const client = await getAuthClientForUrl(cloudRunEndpoint);- const authenticatedResponse = await client.request({+ const renderResponse = await client.request({url: cloudRunUrl,method: 'POST',data,});- return authenticatedResponse.data as RenderStillOnCloudrunOutput;+ return renderResponse.data as RenderStillOnCloudrunOutput;};diff --git a/packages/cloudrun/src/cli/commands/render/renderStill.ts b/packages/cloudrun/src/cli/commands/render/renderStill.tsindex 8bf671adcd..69f7dda6b2 100644--- a/packages/cloudrun/src/cli/commands/render/renderStill.ts+++ b/packages/cloudrun/src/cli/commands/render/renderStill.ts@@ -103,7 +103,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}forceHeight: height,forceWidth: width,forceBucketName,- outputFile: outName,+ outName,logLevel: ConfigInternals.Logging.getLogLevel(),});doneIn = Date.now() - renderStart;diff --git a/packages/cloudrun/src/functions/helpers/payloads.ts b/packages/cloudrun/src/functions/helpers/payloads.tsindex 6de7c9e794..9ed58c3197 100644--- a/packages/cloudrun/src/functions/helpers/payloads.ts+++ b/packages/cloudrun/src/functions/helpers/payloads.ts@@ -59,7 +59,7 @@ export const CloudRunPayload = z.discriminatedUnion('type', [envVariables: z.record(z.string()).optional(),chromiumOptions: chromiumOptions.optional(),outputBucket: z.string(),- outputFile: z.string().optional(),+ outName: z.string().optional(),frame: z.number(),logLevel,}),diff --git a/packages/cloudrun/src/functions/render-still-single-thread.ts b/packages/cloudrun/src/functions/render-still-single-thread.tsindex bbd31a442c..ba92754e8d 100644--- a/packages/cloudrun/src/functions/render-still-single-thread.ts+++ b/packages/cloudrun/src/functions/render-still-single-thread.ts@@ -55,7 +55,7 @@ export const renderStillSingleThread = async (const uploadedResponse = await storage.bucket(body.outputBucket).upload(tempFilePath, {- destination: `renders/${renderId}/${body.outputFile ?? 'out.png'}`,+ destination: `renders/${renderId}/${body.outName ?? 'out.png'}`,predefinedAcl: publicUpload ? 'publicRead' : 'projectPrivate',});diff --git a/packages/docs/docs/cloudrun/rendermediaoncloudrun.md b/packages/docs/docs/cloudrun/rendermediaoncloudrun.mdindex f8e88e21d4..def2f22b64 100644--- a/packages/docs/docs/cloudrun/rendermediaoncloudrun.md+++ b/packages/docs/docs/cloudrun/rendermediaoncloudrun.md@@ -5,8 +5,6 @@ title: renderMediaOnCloudrun()crumb: "Cloud Run API"----import { MinimumFramesPerLambda } from "../../components/lambda/default-frames-per-lambda";-Kicks off a media rendering process on Remotion Cloud Run.Requires a [service](/docs/cloudrun/deployservice) to already be deployed to execute the render.@@ -51,7 +49,7 @@ The name of the Cloud Run service which should be used to perform the render. Th### `region`-In which region your Cloud Run service is deployed. It's highly recommended that your Remotion site is also in the same region.+In which [GCP region](/docs/cloudrun/region-selection) your Cloud Run service is deployed. It's highly recommended that your Remotion site is also in the same region.### `serveUrl`@@ -221,19 +219,19 @@ Disables audio output. See also [`renderMedia() -> muted`](/docs/renderer/render### `forceWidth?`-_available_+_optional_Overrides default composition width.### `forceHeight?`-_available_+_optional_Overrides default composition height.### `logLevel?`-_available_+_optional_One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged inside the Lambda function. Defaults to `info`.diff --git a/packages/docs/docs/cloudrun/renderstilloncloudrun.md b/packages/docs/docs/cloudrun/renderstilloncloudrun.mdindex 1333ed77b7..e4b03a605d 100644--- a/packages/docs/docs/cloudrun/renderstilloncloudrun.md+++ b/packages/docs/docs/cloudrun/renderstilloncloudrun.md@@ -1 +1,205 @@-TODO+---+image: /generated/articles-docs-cloudrun-renderstilloncloudrun.png+id: renderstilloncloudrun+title: renderStillOnCloudrun()+crumb: "Cloud Run API"+---++Kicks off a still rendering process on Remotion Cloud Run.++Requires a [service](/docs/cloudrun/deployservice) to already be deployed to execute the render.+A [site](/docs/cloudrun/deploysite) or a [Serve URL](/docs/terminology#serve-url) needs to be specified to determine what will be rendered.++## Example++```tsx twoslash+// @module: esnext+// @target: es2017+// ---cut---+import { renderStillOnCloudrun } from "@remotion/cloudrun";++const result = await renderStillOnCloudrun({+ region: "us-east1",+ serviceName: "remotion-render-bds9aab",+ composition: "MyStill",+ serveUrl:+ "https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",+});++console.log(result.bucketName);+console.log(result.renderId);+```++## Arguments++An object with the following properties:++### `cloudRunUrl?`++_optional. Required if serviceName not supplied_++The url of the Cloud Run service which should be used to perform the render. You must set either cloudRunUrl or serviceName, but not both++### `serviceName?`++_optional. Required if cloudRunUrl not supplied_++The name of the Cloud Run service which should be used to perform the render. This is used in conjunction with the region to determine the service endpoint, as the same service name can exist across multiple regions.++### `region`++In which [GCP region](/docs/cloudrun/region-selection) your Cloud Run service is deployed. It's highly recommended that your Remotion site is also in the same region.++### `serveUrl`++A URL pointing to a Remotion project. Use [`deploySite()`](/docs/cloudrun/deploysite) to deploy a Remotion project.++### `composition`++The `id` of the [composition](/docs/composition) you want to render.++### `inputProps?`++_optional_++React props that are passed to your composition. You define the shape of the props that the component accepts.++### `privacy?`++_optional_++One of:++- `"public"` (_default_): The rendered still is publicly accessible under the Cloud Storage URL.+- `"private"`: The rendered still is not publicly available, but is available within the GCP project to those with the correct permissions.++### `forceBucketName?`++_optional_++Specify a specific bucket name to be used for the output. The resulting Google Cloud Storage URL will be in the format `gs://{bucket-name}/renders/{render-id}/{file-name}`. If not set, Remotion will choose the right bucket to use based on the region.++### `jpegQuality?`++_optional_++See [`renderStill() -> jpegQuality`](/docs/renderer/render-still#jpegquality).++### `imageFormat?`++_optional_++See [`renderStill() -> imageFormat`](/docs/renderer/render-still#imageformat).++### `scale?`++_optional_++Scales the output dimensions by a factor. See [Scaling](/docs/scaling) to learn more about this feature.++### `envVariables?`++_optional_++See [`renderStill() -> envVariables`](/docs/renderer/render-still#envvariables).++### `frame?`++_optional_++Which frame of the composition should be rendered. Frames are zero-indexed, and negative values are allowed, with -1 being the last frame.++### `chromiumOptions?`++_optional_++Allows you to set certain Chromium / Google Chrome flags. See: [Chromium flags](/docs/chromium-flags).++#### `disableWebSecurity`++_boolean - default `false`_++This will most notably disable CORS among other security features.++#### `ignoreCertificateErrors`++_boolean - default `false`_++Results in invalid SSL certificates, such as self-signed ones, being ignored.++#### `gl`++_string_++Select the OpenGL renderer backend for Chromium.+Accepted values:++- `"angle"`,+- `"egl"`,+- `"swiftshader"`+- `"swangle"`+- `null` - Chromiums default++### `forceWidth?`++_optional_++Overrides default composition width.++### `forceHeight?`++_optional_++Overrides default composition height.++### `logLevel?`++_optional_++One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged inside the Lambda function. Defaults to `info`.++### `outName?`++_optional_++The file name of the still output.++It can either be:++- `undefined` - it will default to `out` plus the appropriate file extension, for example: `renders/${renderId}/out.mp4`.+- A `string` - it will get saved to the same Cloud Storage bucket as your site under the key `renders/{renderId}/{outName}`.++## Return value++Returns a promise resolving to an object containing the following:++### `renderId`++A unique alphanumeric identifier for this render. Useful for obtaining status and finding the relevant files in the Cloud Storage bucket.++### `bucketName`++The Cloud Storage bucket name in which all files are being saved.++### `privacy`++Privacy of the output file, either:++- "public-read" - Publicly accessible under the Cloud Storage URL.+- "project-private" - Not publicly available, but is available within the GCP project to those with the correct permissions.++### `publicUrl`++If the privacy is set to public, this will be the publicly accessible URL of the rendered file. If the privacy is not public, this will be null.++### `cloudStorageUri`++Google Storage path, beginning with `gs://{bucket-name}`. Can be used with the [gsutil](https://cloud.google.com/storage/docs/gsutil) CLI tool.++### `size`++Size of the rendered still in KB.++## See also++- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/cloudrun/src/api/render-still-on-cloudrun.ts)