Skip to content

🎥 Make videos programmatically with React

logging + versioning

Jonny Burger69f97e839198
diff --git a/packages/cloudrun/container/package.json b/packages/cloudrun/container/package.json
index 25c3007e01..bd33d5708b 100644
--- a/packages/cloudrun/container/package.json
+++ b/packages/cloudrun/container/package.json
@@ -1,6 +1,6 @@
{
"name": "cloud-run-render",
- "version": "0.1.0",
+ "version": "3.3.95",
"description": "Render media and stills on GCP Cloud Run",
"main": "dist/index.js",
"scripts": {
@@ -9,4 +9,4 @@
"dependencies": {
"@google-cloud/functions-framework": "^3.1.3"
}
-}
\ No newline at end of file
+}
diff --git a/packages/cloudrun/src/functions/index.ts b/packages/cloudrun/src/functions/index.ts
index 2946ecb76d..167db2811b 100644
--- a/packages/cloudrun/src/functions/index.ts
+++ b/packages/cloudrun/src/functions/index.ts
@@ -1,5 +1,6 @@
import type * as ff from '@google-cloud/functions-framework';
import {RenderInternals} from '@remotion/renderer';
+import {Log} from '../cli/log';
import type {ErrorResponsePayload} from './helpers/payloads';
import {CloudRunPayload} from './helpers/payloads';
import {renderMediaSingleThread} from './render-media-single-thread';
@@ -25,6 +26,7 @@ const renderOnCloudRun = async (req: ff.Request, res: ff.Response) => {
.send('Invalid render type, must be either "media" or "still"');
}
} catch (err) {
+ Log.error('Error while rendering', err);
const response: ErrorResponsePayload = {
error: (err as Error).message,
status: 'error',
diff --git a/packages/cloudrun/src/functions/render-still-single-thread.ts b/packages/cloudrun/src/functions/render-still-single-thread.ts
index d3eee7b382..bbd31a442c 100644
--- a/packages/cloudrun/src/functions/render-still-single-thread.ts
+++ b/packages/cloudrun/src/functions/render-still-single-thread.ts
@@ -46,6 +46,7 @@ export const renderStillSingleThread = async (
frame: body.frame,
verbose: RenderInternals.isEqualOrBelowLogLevel(body.logLevel, 'verbose'),
});
+ Log.info('Still rendered');
const storage = new Storage();
@@ -58,6 +59,8 @@ export const renderStillSingleThread = async (
predefinedAcl: publicUpload ? 'publicRead' : 'projectPrivate',
});
+ Log.info('Still uploaded');
+
const uploadedFile = uploadedResponse[0];
const renderMetadata = await uploadedFile.getMetadata();
const responseData: RenderStillOnCloudrunOutput = {
diff --git a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar
index 2bf785fda9..4cbc18cb56 100644
Binary files a/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/src/gcpInstaller/gcpInstaller.tar differ
diff --git a/packages/example/testcloudrun.sh b/packages/example/testcloudrun.sh
index 2df3f5e927..77f25129df 100644
--- a/packages/example/testcloudrun.sh
+++ b/packages/example/testcloudrun.sh
@@ -10,4 +10,4 @@ cd example
pnpm exec remotion cloudrun services rmall -f
pnpm exec remotion cloudrun sites create --site-name=testbed
pnpm exec remotion cloudrun services deploy --cpuLimit=4.0
-pnpm exec remotion cloudrun render still testbed react-svg --log=verbose
+pnpm exec remotion cloudrun render media testbed react-svg --log=verbose
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index 46ac0e0eaa..89f805dff2 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -1,7 +1,8 @@
-import fs, {promises} from 'node:fs';
+import {promises} from 'node:fs';
import path from 'node:path';
import type {TAsset} from 'remotion';
import {Internals} from 'remotion';
+import {VERSION} from 'remotion/version';
import {calculateAssetPositions} from './assets/calculate-asset-positions';
import {convertAssetsToFileUrls} from './assets/convert-assets-to-file-urls';
import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';
@@ -44,12 +45,6 @@ import {truthy} from './truthy';
import {validateEvenDimensionsWithCodec} from './validate-even-dimensions-with-codec';
import {validateBitrate} from './validate-videobitrate';
-const packageJsonPath = path.join(__dirname, '..', 'package.json');
-
-const packageJson = fs.existsSync(packageJsonPath)
- ? JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
- : null;
-
export type StitcherOptions = {
audioBitrate?: string | null;
videoBitrate?: string | null;
@@ -421,13 +416,7 @@ const spawnFfmpeg = async (
resolvedAudioCodec ? ['-b:a', options.audioBitrate || '512K'] : null,
// Ignore metadata that may come from remote media
['-map_metadata', '-1'],
- [
- '-metadata',
- `comment=` +
- [`Made with Remotion`, packageJson ? packageJson.version : null].join(
- ' '
- ),
- ],
+ ['-metadata', `comment=` + [`Made with Remotion ${VERSION}`].join(' ')],
options.force ? '-y' : null,
options.outputLocation ?? tempFile,
];
@@ -518,8 +507,9 @@ export const stitchFramesToVideo = async (
const remotionRoot = findRemotionRoot();
const {task, getLogs} = await spawnFfmpeg(options, remotionRoot);
- const happyPath = task.catch(() => {
- throw new Error(getLogs());
+ const happyPath = task.catch((err) => {
+ Log.error('Error while stitching frames to video', err);
+ throw new Error((err as Error).stack + ' FFmpeg logs:' + getLogs());
});
warnAboutM2Bug(options.codec ?? null, options.pixelFormat ?? null);