🎥 Make videos programmatically with React
nice
Jonny Burgerce1d5f6ebcd3
diff --git a/packages/docs/docs/lambda/ruby.mdx b/packages/docs/docs/lambda/ruby.mdxnew file mode 100644index 0000000000..9925beb955--- /dev/null+++ b/packages/docs/docs/lambda/ruby.mdx@@ -0,0 +1,86 @@+---+image: /generated/articles-docs-lambda-ruby.png+title: Triggering renders from Ruby+slug: /lambda/ruby+sidebar_label: Rendering from Ruby+crumb: '@remotion/lambda'+---++_available from v4.0.232_++To trigger a Lambda render using Ruby, install the [`remotion_lambda`](https://rubygems.org/gems/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()`](/docs/lambda/render-media-on-lambda), [`renderStillOnLambda()`](/docs/lambda/render-still-on-lambda) and [`getRenderProgressOnLambda()`](/docs/lambda/get-render-progress).+- 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_case` versions of the Node.js field names.+- Nested field names, e.g. `s3_output_provder.accessKeyId` have the original `camelCase` capitalization.+- All fields of the response payloads are in `camelCase` like 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++```rb title="Rendering a video from Ruby"+require '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 a still++```ruby title="Rendering a still from Ruby"+require '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+```++## See also++- [Ruby gem `remotion_lambda`](https://rubygems.org/gems/remotion_lambda)+- [Source code for this SDK](https://github.com/remotion-dev/remotion/tree/main/packages/lambda-ruby)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 9606e23704..2bd4dc7f2b 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -836,6 +836,7 @@ module.exports = {'lambda/php','lambda/go','lambda/python',+ 'lambda/ruby','lambda/serverless-framework-integration','lambda/insights','lambda/multiple-buckets',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 10c24e9439..465864c2a4 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -2447,6 +2447,13 @@ export const articles = [compId: 'articles-docs-lambda-feb-2022-outage',crumb: null,},+ {+ id: 'lambda/ruby',+ title: 'Triggering renders from Ruby',+ relativePath: 'docs/lambda/ruby.mdx',+ compId: 'articles-docs-lambda-ruby',+ crumb: '@remotion/lambda',+ },{id: 'getrenderprogress',title: 'getRenderProgress()',diff --git a/packages/docs/static/generated/articles-docs-lambda-ruby.png b/packages/docs/static/generated/articles-docs-lambda-ruby.pngnew file mode 100644index 0000000000..b6caabe2abBinary files /dev/null and b/packages/docs/static/generated/articles-docs-lambda-ruby.png differdiff --git a/packages/example/testlambdaintegrations.mjs b/packages/example/testlambdaintegrations.mjsindex dd7c2b46f4..de091417a7 100644--- a/packages/example/testlambdaintegrations.mjs+++ b/packages/example/testlambdaintegrations.mjs@@ -9,17 +9,6 @@ const functionName = execSync(`pnpm exec remotion lambda functions ls -q`).split(' ')[0];console.log('=== Ruby (Still) ===');-execSync(`ruby lib/test_render_spec_still.rb`, {- env: {- // eslint-disable-next-line no-undef- ...process.env,- REMOTION_APP_REGION: 'eu-central-1',- REMOTION_APP_FUNCTION_NAME: functionName,- REMOTION_APP_SERVE_URL: 'testbed-v6',- },- cwd: '../lambda-ruby',- stdio: 'inherit',-});execSync(`ruby lib/test_render_spec_media.rb`, {env: {@@ -32,54 +21,3 @@ execSync(`ruby lib/test_render_spec_media.rb`, {cwd: '../lambda-ruby',stdio: 'inherit',});--console.log('=== Golang ===');-execSync(`go run main.go`, {- env: {- // eslint-disable-next-line no-undef- ...process.env,- REMOTION_APP_REGION: 'eu-central-1',- REMOTION_APP_FUNCTION_NAME: functionName,- REMOTION_APP_SERVE_URL: 'testbed-v6',- },- cwd: '../lambda-go-example',- stdio: 'inherit',-});-console.log('=== PHP ===');-execSync(`php src/render.php`, {- env: {- // eslint-disable-next-line no-undef- ...process.env,- REMOTION_APP_REGION: 'eu-central-1',- REMOTION_APP_FUNCTION_NAME: functionName,- REMOTION_APP_SERVE_URL: 'testbed-v6',- },- cwd: '../lambda-php-example',- stdio: 'inherit',-});--console.log('=== Python(render media) ===');-execSync(`python testclient_render_media.py`, {- env: {- // eslint-disable-next-line no-undef- ...process.env,- REMOTION_APP_REGION: 'eu-central-1',- REMOTION_APP_FUNCTION_NAME: functionName,- REMOTION_APP_SERVE_URL: 'testbed-v6',- },- cwd: '../lambda-python',- stdio: 'inherit',-});--console.log('=== Python(render still) ===');-execSync(`python testclient_render_still.py`, {- env: {- // eslint-disable-next-line no-undef- ...process.env,- REMOTION_APP_REGION: 'eu-central-1',- REMOTION_APP_FUNCTION_NAME: functionName,- REMOTION_APP_SERVE_URL: 'testbed-v6',- },- cwd: '../lambda-python',- stdio: 'inherit',-});diff --git a/packages/it-tests/src/monorepo/ruby-package.test.ts b/packages/it-tests/src/monorepo/ruby-package.test.tsindex a4fb5d5894..b5f96ccdb9 100644--- a/packages/it-tests/src/monorepo/ruby-package.test.ts+++ b/packages/it-tests/src/monorepo/ruby-package.test.ts@@ -6,11 +6,27 @@ import path from 'path';import {VERSION} from 'remotion';const rubySdk = path.join(__dirname, '..', '..', '..', 'lambda-ruby');-test('Set the right version for Ruby', () => {+test('Set the right version for Ruby in version.rb', () => {const versionPath = path.join(rubySdk, 'lib', 'version.rb');fs.writeFileSync(versionPath, `VERSION = "${VERSION}"`);});+test('Set the right version for Ruby in remotion_lambda.gemspec', () => {+ const gemspecPath = path.join(rubySdk, 'remotion_lambda.gemspec');++ const contents = fs+ .readFileSync(gemspecPath, 'utf-8')+ .split('\n')+ .map((l) => {+ if (l.includes('s.version')) {+ return ` s.version = "${VERSION}"`;+ }+ return l;+ })+ .join('\n');++ fs.writeFileSync(gemspecPath, contents);+});test('Render progress payload', () => {const output = execSync('ruby lib/render_progress_payload_spec.rb', {@@ -41,7 +57,7 @@ test('Render Media payload', async () => {region: 'us-east-1',composition: 'react-svg',functionName: 'remotion-render',- serveUrl: 'testbed',+ serveUrl: 'testbed-v6',codec: 'h264',inputProps: {hi: 'there',@@ -109,7 +125,7 @@ test('Render Still payload', async () => {region: 'us-east-1',composition: 'still-helloworld',functionName: 'remotion-render',- serveUrl: 'testbed',+ serveUrl: 'testbed-v6',inputProps: {message: 'Hello from props!',},diff --git a/packages/lambda-ruby/lib/render_still_on_lambda_payload_spec.rb b/packages/lambda-ruby/lib/render_still_on_lambda_payload_spec.rbindex 89a3241c04..bbcb21a8b3 100644--- a/packages/lambda-ruby/lib/render_still_on_lambda_payload_spec.rb+++ b/packages/lambda-ruby/lib/render_still_on_lambda_payload_spec.rb@@ -1,9 +1,7 @@require_relative 'render_still_on_lambda_payload'require 'json'-# Call get_render_media_on_lambda with sample datapayload = get_render_still_on_lambda_payload(- bucket_name: nil,composition: "still-helloworld",download_behavior: {type: "play-in-browser",diff --git a/packages/lambda-ruby/lib/test_render_spec_media.rb b/packages/lambda-ruby/lib/test_render_spec_media.rbindex 3851405a99..20d9ef9067 100644--- a/packages/lambda-ruby/lib/test_render_spec_media.rb+++ b/packages/lambda-ruby/lib/test_render_spec_media.rb@@ -1,5 +1,6 @@require_relative 'sdk'require_relative 'render_media_on_lambda_payload'+require_relative 'render_progress_payload'client = RemotionLambda::Client.new(region: 'eu-central-1',@@ -19,6 +20,16 @@ payload = get_render_media_on_lambda_payload()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+diff --git a/packages/lambda-ruby/remotion_lambda.gemspec b/packages/lambda-ruby/remotion_lambda.gemspecindex b3f6b9aeb5..703fbbba4f 100644--- a/packages/lambda-ruby/remotion_lambda.gemspec+++ b/packages/lambda-ruby/remotion_lambda.gemspec@@ -1,11 +1,11 @@Gem::Specification.new do |s|s.name = "remotion_lambda"- s.version = "0.0.1"+ s.version = "4.0.232"s.summary = "Remotion Lambda SDK"s.description = "A Ruby SDK for Remotion Lambda"s.authors = ["Jonny Burger"]s.email = "[email protected]"- s.files = ["lib/sdk.rb"]+ s.files = ["lib/sdk.rb", "lib/s3_output_provider.rb", "lib/render_progress_payload.rb", "lib/render_media_on_lambda_payload.rb", "lib/render_still_on_lambda_payload.rb"]s.homepage ="https://rubygems.org/gems/remotion_lambda"s.license = "MIT"