Triggering renders from Rubyv4.0.232
To trigger a Lambda render using Ruby, install the remotion_lambda gem.
The version should be the same version of the @remotion/lambda NPM package version that you used to deploy your function.
Notes
- This module is experimental and might have breaking changes in minor versions. Check on this page for up-to-date examples.
- The implemented methods are
renderMediaOnLambda(),renderFramesOnLambda(),renderStillOnLambda(),getRenderProgressOnLambda(), andcancelRenderOnLambda(). - We will maintain the Ruby SDK to ensure the fields stay in sync with the Node.js functions.
- The fields in the input payload are
snake_caseversions of the Node.js field names. - Nested field names, e.g.
s3_output_provder.accessKeyIdhave the originalcamelCasecapitalization. - All fields of the response payloads are in
camelCaselike the original Node.js functions. - The maximum input payload size is around 60KB. The workaround for bigger payloads where they get uploaded to S3 is not implemented in the Ruby SDK.
Rendering a video and getting the progress
Rendering a video from Rubyrequire 'remotion_lambda' client = RemotionLambda::Client.new( region: 'eu-central-1', ) function_name = ENV.fetch('REMOTION_APP_FUNCTION_NAME') payload = get_render_media_on_lambda_payload( composition: "still-helloworld", download_behavior: { type: "play-in-browser", }, codec: "h264", input_props: { message: "Hello from props!", } ) res = client.render_media_on_lambda(function_name, payload) puts res while true render_progress_payload = get_render_progress_payload( render_id: res["renderId"], bucket_name: res["bucketName"], ) progress = client.get_render_progress(function_name, render_progress_payload) puts progress["overallProgress"] break if progress["done"] break if progress["fatalErrorEncountered"] sleep 1 end
Rendering an image sequencev4.0.535
Use get_render_frames_on_lambda_payload() and render_frames_on_lambda(). Images default to PNG; the options follow renderFramesOnLambda().
Rendering an image sequence from Rubypayload = get_render_frames_on_lambda_payload( composition: "main", serve_url: ENV.fetch('REMOTION_APP_SERVE_URL'), frame_range: [0, 99], frames_per_lambda: 20, output_prefix: "exports/my-sequence/", image_sequence_pattern: "element-[frame].[ext]", ) res = client.render_frames_on_lambda(function_name, payload) puts res
Poll get_render_progress() until done or fatalErrorEncountered. framesUploaded reports uploaded frames, and outputSequence['manifestUrl'] points to the completed manifest. output_prefix also accepts a hash with bucketName, keyPrefix, and optional s3OutputProvider.
Cancelling a renderv4.0.515
Enable cancellation in the render payload, then call cancel_render_on_lambda():
Cancelling a render from Rubypayload = get_render_media_on_lambda_payload( composition: "still-helloworld", codec: "h264", enable_cancellation: true, ) res = client.render_media_on_lambda(function_name, payload) client.cancel_render_on_lambda(res["bucketName"], res["renderId"])
Rendering a still
Rendering a still from Rubyrequire 'remotion_lambda' client = RemotionLambda::Client.new( region: 'eu-central-1', ) function_name = ENV.fetch('REMOTION_APP_FUNCTION_NAME') payload = get_render_still_on_lambda_payload( composition: "still-helloworld", input_props: { message: "Hello from props!", } ) res = client.render_still_on_lambda(function_name, payload) puts res