🎥 Make videos programmatically with React
passing through all extra rendering props
Matt McGillivray8669c93233a3
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.tsindex ade42b8358..cb0b2ffd20 100644--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts@@ -22,6 +22,32 @@ export type RenderMediaOnCloudrunInput = {outputBucket: string;outputFile?: string;updateRenderProgress?: (progress: number) => void;+ jpegQuality?: number;+ audioCodec?: 'mp3' | 'aac' | 'pcm-16' | 'opus';+ audioBitrate?: string;+ videoBitrate?: string;+ proResProfile?:+ | '4444-xq'+ | '4444'+ | 'hq'+ | 'standard'+ | 'light'+ | 'proxy'+ | undefined;+ crf?: number;+ pixelFormat?:+ | 'yuv420p'+ | 'yuva420p'+ | 'yuv422p'+ | 'yuv444p'+ | 'yuv420p10le'+ | 'yuv422p10le'+ | 'yuv444p10le'+ | 'yuva444p10le';+ imageFormat?: 'png' | 'jpeg' | 'none';+ scale?: number;+ everyNthFrame?: number;+ numberOfGifLoops?: number;};export type RenderMediaOnCloudrunOutput = {@@ -66,6 +92,17 @@ export const renderMediaOnCloudrun = async ({privacy,outputFile,updateRenderProgress,+ jpegQuality,+ audioCodec,+ audioBitrate,+ videoBitrate,+ proResProfile,+ crf,+ pixelFormat,+ imageFormat,+ scale,+ everyNthFrame,+ numberOfGifLoops,}: RenderMediaOnCloudrunInput): Promise<RenderMediaOnCloudrunOutput> => {const actualCodec = validateCloudrunCodec(codec);validateServeUrl(serveUrl);@@ -98,6 +135,17 @@ export const renderMediaOnCloudrun = async ({outputBucket,privacy,outputFile,+ jpegQuality,+ audioCodec,+ audioBitrate,+ videoBitrate,+ proResProfile,+ crf,+ pixelFormat,+ imageFormat,+ scale,+ everyNthFrame,+ numberOfGifLoops,};if (authenticatedRequest) {diff --git a/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts b/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.tsindex b1328e414f..87d27d55b9 100644--- a/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts+++ b/packages/cloudrun/src/cli/commands/render/helpers/renderArgsCheck.ts@@ -119,6 +119,28 @@ export const renderArgsCheck = async (const authenticatedRequest = !parsedCloudrunCli['unauthenticated-request'];+ const jpegQuality = parsedCloudrunCli['jpeg-quality'];++ const audioCodec = parsedCloudrunCli['audio-codec'];++ const audioBitrate = parsedCloudrunCli['audio-bitrate'];++ const videoBitrate = parsedCloudrunCli['video-bitrate'];++ const proResProfile = parsedCloudrunCli['prores-profile'];++ const {crf} = parsedCloudrunCli;++ const pixelFormat = parsedCloudrunCli['pixel-format'];++ const imageFormat = parsedCloudrunCli['image-format'];++ const {scale} = parsedCloudrunCli;++ const everyNthFrame = parsedCloudrunCli['every-nth-frame'];++ const numberOfGifLoops = parsedCloudrunCli['number-of-gif-loops'];+return {serveUrl,cloudRunUrl,@@ -131,5 +153,16 @@ export const renderArgsCheck = async (privacy,authenticatedRequest,downloadName,+ jpegQuality,+ audioCodec,+ audioBitrate,+ videoBitrate,+ proResProfile,+ crf,+ pixelFormat,+ imageFormat,+ scale,+ everyNthFrame,+ numberOfGifLoops,};};diff --git a/packages/cloudrun/src/cli/commands/render/renderMedia.ts b/packages/cloudrun/src/cli/commands/render/renderMedia.tsindex ae280b930a..57563dc9ec 100644--- a/packages/cloudrun/src/cli/commands/render/renderMedia.ts+++ b/packages/cloudrun/src/cli/commands/render/renderMedia.ts@@ -25,6 +25,17 @@ export const renderMediaSubcommand = async (downloadName,privacy,authenticatedRequest,+ jpegQuality,+ audioCodec,+ audioBitrate,+ videoBitrate,+ proResProfile,+ crf,+ pixelFormat,+ imageFormat,+ scale,+ everyNthFrame,+ numberOfGifLoops,} = await renderArgsCheck(RENDER_MEDIA_SUBCOMMAND, args, remotionRoot);// Todo: Check cloudRunUrl is valid, as the error message is obtuse@@ -41,6 +52,7 @@ Sending request to Cloud Run:Output Bucket = ${outputBucket}Output File = ${outName ?? 'out.mp4'}Output File Privacy = ${privacy}+${downloadName ? ` Downloaded File = ${downloadName}` : ''}`.trim()));@@ -88,6 +100,17 @@ Sending request to Cloud Run:privacy,outputFile: outName,updateRenderProgress,+ jpegQuality,+ audioCodec,+ audioBitrate,+ videoBitrate,+ proResProfile,+ crf,+ pixelFormat,+ imageFormat,+ scale,+ everyNthFrame,+ numberOfGifLoops,});renderProgress.doneIn = Date.now() - renderStart;updateProgress();diff --git a/packages/cloudrun/src/functions/render-media-single-thread.ts b/packages/cloudrun/src/functions/render-media-single-thread.tsindex 4822675960..6b7398e603 100644--- a/packages/cloudrun/src/functions/render-media-single-thread.ts+++ b/packages/cloudrun/src/functions/render-media-single-thread.ts@@ -32,6 +32,17 @@ export const renderMediaSingleThread = async (codec: req.body.codec,outputLocation: tempFilePath,inputProps: req.body.inputProps,+ jpegQuality: req.body.jpegQuality,+ audioCodec: req.body.audioCodec,+ audioBitrate: req.body.audioBitrate,+ videoBitrate: req.body.videoBitrate,+ crf: req.body.crf,+ pixelFormat: req.body.pixelFormat,+ imageFormat: req.body.imageFormat,+ scale: req.body.scale,+ proResProfile: req.body.proResProfile,+ everyNthFrame: req.body.everyNthFrame,+ numberOfGifLoops: req.body.numberOfGifLoops,onProgress,});diff --git a/packages/cloudrun/src/functions/render-still-single-thread.ts b/packages/cloudrun/src/functions/render-still-single-thread.tsindex 8d0f32b1d4..4198f82189 100644--- a/packages/cloudrun/src/functions/render-still-single-thread.ts+++ b/packages/cloudrun/src/functions/render-still-single-thread.ts@@ -21,6 +21,9 @@ export const renderStillSingleThread = async (serveUrl: req.body.serveUrl,output: tempFilePath,inputProps: req.body.inputProps,+ jpegQuality: req.body.jpegQuality,+ imageFormat: req.body.imageFormat,+ scale: req.body.scale,});const storage = new Storage();diff --git a/packages/docs/docs/cloudrun/cli/render.md b/packages/docs/docs/cloudrun/cli/render.mdindex 772f1ee290..af5e46041f 100644--- a/packages/docs/docs/cloudrun/cli/render.md+++ b/packages/docs/docs/cloudrun/cli/render.md@@ -62,27 +62,45 @@ One of:- `"public"` (_default_): The rendered media is publicly accessible under the Cloud Storage URL.- `"private"`: The rendered media is not publicly available, but is available within the GCP project to those with the correct permissions.-### `--max-retries`--How many times a single chunk is being retried if it fails to render. Default `1`.-### `--jpeg-quality`[Value between 0 and 100 for JPEG rendering quality](/docs/config#setjpegquality). Doesn't work when PNG frames are rendered.-### `--muted` <AvailableFrom v="3.2.1" />+### `--image-format`++[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setvideoimageformat) The default image format is `jpeg`.++### `--scale`++[Scales the output frames by the factor you pass in.](/docs/scaling) For example, a 1280x720px frame will become a 1920x1080px frame with a scale factor of `1.5`. Vector elements like fonts and HTML markups will be rendered with extra details.++### `--env-file`++Specify a location for a dotenv file. Default `.env`.++### `--frames`++[Render a subset of a video](/docs/config#setframerange). Example: `--frames=0-9` to select the first 10 frames. To render a still, use the [`still`](/docs/cloudrun/cli/still) command.++### `--out-name`++The file name of the media output as stored in the Cloud Storage bucket. By default, it is `out` plus the appropriate file extension, for example: `out.mp4`. Must match `/([0-9a-zA-Z-!_.*'()/]+)/g`.-[Disables audio output.](/docs/config#setmuted) This option may only be used when rendering a video.+### `--service-name`++Specify the name of the service which should be used to perform the render.++## Media Rendering Specific Flags### `--codec`[`h264` or `h265` or `png` or `vp8` or `mp3` or `aac` or `wav` or `prores`](/docs/config#setcodec). If you don't supply `--codec`, it will use `h264`.-### `--audio-codec` <AvailableFrom v="3.3.42" />+### `--audio-codec`[Set which codec the audio should have.](/docs/config#setaudiocodec) For defaults and possible values, refer to the [Encoding guide](/docs/encoding/#audio-codec).-### `--audio-bitrate` <AvailableFrom v="3.2.32" />+### `--audio-bitrate`Specify the target bitrate for the generated audio.The syntax for FFMPEGs `-b:a` parameter should be used.@@ -90,7 +108,7 @@ FFMPEG may encode the video in a way that will not result in the exact audio bitExample values: `128K` for 128 kbps, `1M` for 1 Mbps.Default: `320k`-### `--video-bitrate` <AvailableFrom v="3.2.32" />+### `--video-bitrate`Specify the target bitrate for the generated video.The syntax for FFMPEGs `-b:v` parameter should be used.@@ -110,76 +128,12 @@ Example values: `512K` for 512 kbps, `1M` for 1 Mbps.[Set a custom pixel format. See here for available values.](/docs/config#setpixelformat)-### `--image-format`--[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setvideoimageformat) The default image format is `jpeg`.--### `--scale`--[Scales the output frames by the factor you pass in.](/docs/scaling) For example, a 1280x720px frame will become a 1920x1080px frame with a scale factor of `1.5`. Vector elements like fonts and HTML markups will be rendered with extra details.--### `--env-file`--Specify a location for a dotenv file. Default `.env`.--### `--frames`--[Render a subset of a video](/docs/config#setframerange). Example: `--frames=0-9` to select the first 10 frames. To render a still, use the [`still`](/docs/cloudrun/cli/still) command.--### `--every-nth-frame` <AvailableFrom v="3.1.0" />+### `--every-nth-frame`[Render only every nth frame.](/docs/config#seteverynthframe) This option may only be set when rendering GIFs. This allows you to lower the FPS of the GIF.For example only every second frame, every third frame and so on. Only works for rendering GIFs. [See here for more details.](/docs/render-as-gif)-### `--number-of-gif-loops` <AvailableFrom v="3.1.0" />+### `--number-of-gif-loops`[Set the looping behavior.](/docs/config#setnumberofgifloops) This option may only be set when rendering GIFs. [See here for more details.](/docs/render-as-gif#changing-the-number-of-loops)--### `--out-name`--The file name of the media output as stored in the S3 bucket. By default, it is `out` plus the appropriate file extension, for example: `out.mp4`. Must match `/([0-9a-zA-Z-!_.*'()/]+)/g`.--### `--overwrite` <AvailableFrom v="3.2.25" />--If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether that file will be deleted before the render begins. Default `false`.--An existing file at the output S3 key will conflict with the render and must be deleted beforehand. If this setting is `false` and a conflict occurs, an error will be thrown.--### `--webhook` <AvailableFrom v="3.2.30" />--Sets a webhook to be called when the render finishes or fails. [`renderMediaOnLambda() -> webhook.url`](/docs/cloudrun/rendermediaonlambda#webhook). To be used together with `--webhook-secret`.--### `--webhook-secret` <AvailableFrom v="3.2.30" />--Sets a webhook secret for the webhook (see above). [`renderMediaOnLambda() -> webhook.secret`](/docs/cloudrun/rendermediaonlambda#webhook). To be used together with `--webhook`.--### `--height` <AvailableFrom v="3.2.40" />--[Overrides composition height.](/docs/config#overrideheight)--### `--width` <AvailableFrom v="3.2.40" />--[Overrides composition width.](/docs/config#overridewidth)--### `--function-name` <AvailableFrom v="3.3.38" />--Specify the name of the function which should be used to invoke and orchestrate the render. You only need to pass it if there are multiple functions with different configurations.--### `--renderer-function-name` <AvailableFrom v="3.3.38" />--If specified, this function will be used for rendering the individual chunks. This is useful if you want to use a function with higher or lower power for rendering the chunks than the main orchestration function.--If you want to use this option, the function must be in the same region, the same account and have the same version as the main function.--### `--force-bucket-name` <AvailableFrom v="3.3.42" />--Specify a specific bucket name to be used. [This is not recommended](/docs/cloudrun/multiple-buckets), instead let Remotion discover the right bucket automatically.--### `--ignore-certificate-errors`--Results in invalid SSL certificates in Chrome, such as self-signed ones, being ignored.--### `--disable-web-security`--This will most notably disable CORS in Chrome among other security features.