renderMediaOnCloudrun()
Cloud Run is in Alpha, which means APIs may change in any version and documentation is not yet finished. See the changelog to stay up to date with breaking changes.
Kicks off a media rendering process on Remotion Cloud Run.
Requires a service to already be deployed to execute the render.
A site or a Serve URL needs to be specified to determine what will be rendered.
Example
tsx
import {renderMediaOnCloudrun } from "@remotion/cloudrun/client";constresult = awaitrenderMediaOnCloudrun ({region : "us-east1",serviceName : "remotion-render-bds9aab",composition : "MyVideo",serveUrl :"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",codec : "h264",});if (result .type === "success") {console .log (result .bucketName );console .log (result .renderId );}
tsx
import {renderMediaOnCloudrun } from "@remotion/cloudrun/client";constresult = awaitrenderMediaOnCloudrun ({region : "us-east1",serviceName : "remotion-render-bds9aab",composition : "MyVideo",serveUrl :"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",codec : "h264",});if (result .type === "success") {console .log (result .bucketName );console .log (result .renderId );}
Import from @remotion/cloudrun/client
to not import the whole renderer, which cannot be bundled.
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 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()
to deploy a Remotion project.
composition
The id
of the composition you want to render.
codec
Which codec should be used to encode the video.
Video codecs h264
, vp8
and prores
are supported.
Audio codecs mp3
, aac
and wav
are also supported.
See also renderMedia() -> codec
.
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 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.
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.
updateRenderProgress?
optional
A callback that is called with the progress of the render.
audioCodec?
optional
Choose the encoding of your audio.
- Choose
pcm-16
if you need uncompressed audio. - Not all video containers support all audio codecs.
- This option takes precedence if the
codec
option also specifies an audio codec.
Refer to the Encoding guide to see defaults and supported combinations.
jpegQuality?
optional
See renderMedia() -> jpegQuality
.
audioBitrate?
optional
Specify the target bitrate for the generated video. The syntax for FFmpeg's-b:a
parameter should be used. FFmpeg may encode the video in a way that will not result in the exact audio bitrate specified. Example values: 512K
for 512 kbps, 1M
for 1 Mbps. Default: 320k
videoBitrate?
optional
Specify the target bitrate for the generated video. The syntax for FFmpeg's-b:v
parameter should be used. FFmpeg may encode the video in a way that will not result in the exact video bitrate specified. Example values: 512K
for 512 kbps, 1M
for 1 Mbps.bufferSize?
v4.0.78
The value for the -bufsize
flag of FFmpeg. Should be used in conjunction with the encoding max rate flag.maxRate?
v4.0.78
The value for the -maxrate
flag of FFmpeg. Should be used in conjunction with the encoding buffer size flag.proResProfile?
optional
See renderMedia() -> proResProfile
.
optional
x264Preset?
Sets a x264 preset profile. Only applies to videos rendered with h264
codec.Possible values:
superfast
, veryfast
, faster
, fast
, medium
, slow
, slower
, veryslow
, placebo
.Default:
medium
crf?
optional
See renderMedia() -> crf
.
pixelFormat?
optional
See renderMedia() -> pixelFormat
.
imageFormat?
optional
See renderMedia() -> imageFormat
.
scale?
optional
Scales the output dimensions by a factor. See Scaling to learn more about this feature.
everyNthFrame?
optional
Renders only every nth frame. For example only every second frame, every third frame and so on. Only works for rendering GIFs. See here for more details.
numberOfGifLoops?
optional
Allows you to set the number of loops as follows:null
(or omitting in the CLI) plays the GIF indefinitely.0
disables looping1
loops the GIF once (plays twice in total)2
loops the GIF twice (plays three times in total) and so on.
frameRange?
optional
Specify a single frame (a number) or a range of frames (a tuple [number, number]) to be rendered.
envVariables?
optional
See renderMedia() -> envVariables
.
chromiumOptions?
optional
Allows you to set certain Chromium / Google Chrome flags. See: 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
Changelog
- From Remotion v2.6.7 until v3.0.7, the default for Remotion Lambda was
swiftshader
, but from v3.0.8 the default isswangle
(Swiftshader on Angle) since Chrome 101 added support for it. - From Remotion v2.4.3 until v2.6.6, the default was
angle
, however it turns out to have a small memory leak that could crash long Remotion renders.
Select the OpenGL renderer backend for Chromium.
Accepted values:
"angle"
"egl"
"swiftshader"
"swangle"
"vulkan"
(from Remotion v4.0.41)"angle-egl"
(from Remotion v4.0.51)
The default is null
, letting Chrome decide, except on Lambda where the default is "swangle"
muted?
optional
Disables audio output. See also renderMedia() -> muted
.
forceWidth?
optional
Overrides default composition width.
forceHeight?
optional
Overrides default composition height.
logLevel?
One of verbose
, info
, warn
, error
.Determines how much is being logged to the console.
verbose
will also log console.log
's from the browser.Default
info
.outName?
optional
The file name of the media output.
It can either be:
undefined
- it will default toout
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 keyrenders/{renderId}/{outName}
. Make sure to include the file extension at the end of the string.
delayRenderTimeoutInMilliseconds?
optional
A number describing how long the render may take to resolve all delayRender()
calls before it times out. Default: 30000
concurrency?
A number or a string describing how many browser tabs should be opened. Default "50%".
Before v4.0.76, this was "100%" by default. It is now aligned to the other server-side rendering APIs.
enforceAudioTrack?
Render a silent audio track if there wouldn't be any otherwise.
preferLossless?
v4.0.123
Uses a lossless audio codec, if one is available for the codec. If you setaudioCodec
, it takes priority over preferLossless
.offthreadVideoCacheSizeInBytes?
v4.0.23
From v4.0, Remotion has a cache for <OffthreadVideo>
frames. The default is null
, corresponding to half of the system memory available when the render starts.This option allows to override the size of the cache. The higher it is, the faster the render will be, but the more memory will be used.
The used value will be printed when running in verbose mode.
Default:
null
colorSpace?
v4.0.28
Color space to use for the video. Acceptable values: "default"
(default since 5.0), "bt709"
(since v4.0.28), "bt2020-ncl"
(since v4.0.88), "bt2020-cl"
(since v4.0.88), .For best color accuracy, it is recommended to also use
"png"
as the image format to have accurate color transformations throughout.Only since v4.0.83, colorspace conversion is actually performed, previously it would only tag the metadata of the video.
Return value
Returns a promise resolving to an object.
type
Use this to determine the structure of the response. It can either be:
- 'success' - render has been performed successfully.
- 'crash - Cloud Run service has crashed.
Return when type === 'success'
The resulting object contains the following:
type
'success' - render has been performed successfully.
publicUrl?
optional
The publicly accessible URL of the rendered file. Only available when the request had the privacy
property set to 'public'.
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 CLI tool.
size
Size of the rendered media in KB.
Return when type === 'crash'
The resulting object contains the following:
type
'crash' - Cloud Run service has crashed without a response.
cloudRunEndpoint
Endpoint that was called when executing the render. Used by the CLI to parse the service name to determine timeout and memory limit of the service. This can then be used when analysing the logs, to provide a hint as to the reason of the crash.
message
'Service crashed without sending a response. Check the logs in GCP console.' This is used by the CLI for displaying an error message.
requestStartTime
datetime of when the request was made, in UTC format - "2020-01-01T00:00:00+02:00". Can be useful for filtering the logs of the service.
requestCrashTime
datetime of when the crash was detected, in UTC format - "2020-01-01T00:00:00+02:00". Can be useful for filtering the logs of the service.
requestElapsedTimeInSeconds
Seconds elapsed between the request start and crash time. Can be checked against the timeout limit to understand if this was the likely cause of the crash.