Skip to content

🎥 Make videos programmatically with React

passing through all variables to rendering on cloud run

Matt McGillivray897ca6ad8bad
diff --git a/packages/cloudrun/src/api/render-media-on-cloudrun.ts b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
index 6b09d01bec..c3ecc95644 100644
--- a/packages/cloudrun/src/api/render-media-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-media-on-cloudrun.ts
@@ -140,29 +140,28 @@ export const renderMediaOnCloudrun = async ({
}
const data = {
- type: 'media',
composition,
serveUrl,
codec: actualCodec,
inputProps,
- outputBucket,
- privacy,
- outputFile,
jpegQuality,
audioCodec,
audioBitrate,
videoBitrate,
- proResProfile,
crf,
pixelFormat,
imageFormat,
scale,
+ proResProfile,
everyNthFrame,
numberOfGifLoops,
frameRange,
envVariables,
chromiumOptions,
muted,
+ outputBucket,
+ privacy,
+ outputFile,
forceWidth,
forceHeight,
};
diff --git a/packages/cloudrun/src/api/render-still-on-cloudrun.ts b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
index 1e10ddd6d0..4631cfbf51 100644
--- a/packages/cloudrun/src/api/render-still-on-cloudrun.ts
+++ b/packages/cloudrun/src/api/render-still-on-cloudrun.ts
@@ -98,7 +98,6 @@ export const renderStillOnCloudrun = async ({
}
const data = {
- type: 'still',
composition,
serveUrl,
inputProps,
@@ -107,12 +106,12 @@ export const renderStillOnCloudrun = async ({
privacy,
imageFormat,
envVariables,
- frame,
jpegQuality,
chromiumOptions,
scale,
forceWidth,
forceHeight,
+ frame: frame ?? 0,
};
if (authenticatedRequest) {
diff --git a/packages/cloudrun/src/functions/render-media-single-thread.ts b/packages/cloudrun/src/functions/render-media-single-thread.ts
index 4a9e1791a9..608679c250 100644
--- a/packages/cloudrun/src/functions/render-media-single-thread.ts
+++ b/packages/cloudrun/src/functions/render-media-single-thread.ts
@@ -27,7 +27,11 @@ export const renderMediaSingleThread = async (
res.writeHead(200, {'Content-Type': 'text/html'});
await renderMedia({
- composition,
+ composition: {
+ ...composition,
+ height: req.body.forceHeight ?? composition.height,
+ width: req.body.forceWidth ?? composition.width,
+ },
serveUrl: req.body.serveUrl,
codec: req.body.codec,
outputLocation: tempFilePath,
@@ -46,6 +50,8 @@ export const renderMediaSingleThread = async (
onProgress,
frameRange: req.body.frameRange,
envVariables: req.body.envVariables,
+ chromiumOptions: req.body.chromiumOptions,
+ muted: req.body.muted,
});
const storage = new Storage();
diff --git a/packages/cloudrun/src/functions/render-still-single-thread.ts b/packages/cloudrun/src/functions/render-still-single-thread.ts
index 2827c378eb..3fd22dfdc6 100644
--- a/packages/cloudrun/src/functions/render-still-single-thread.ts
+++ b/packages/cloudrun/src/functions/render-still-single-thread.ts
@@ -1,6 +1,6 @@
import type * as ff from '@google-cloud/functions-framework';
import {Storage} from '@google-cloud/storage';
-import {renderStill} from '@remotion/renderer';
+import {RenderInternals, renderStill} from '@remotion/renderer';
import {randomHash} from '../shared/random-hash';
import {getCompositionFromBody} from './helpers/get-composition-from-body';
@@ -17,7 +17,11 @@ export const renderStillSingleThread = async (
const renderId = randomHash({randomInTests: true});
await renderStill({
- composition,
+ composition: {
+ ...composition,
+ height: req.body.forceHeight ?? composition.height,
+ width: req.body.forceWidth ?? composition.width,
+ },
serveUrl: req.body.serveUrl,
output: tempFilePath,
inputProps: req.body.inputProps,
@@ -25,6 +29,11 @@ export const renderStillSingleThread = async (
imageFormat: req.body.imageFormat,
scale: req.body.scale,
envVariables: req.body.envVariables,
+ chromiumOptions: req.body.chromiumOptions,
+ frame: RenderInternals.convertToPositiveFrameIndex({
+ frame: req.body.frame,
+ durationInFrames: composition.durationInFrames,
+ }),
});
const storage = new Storage();