Skip to content

🎥 Make videos programmatically with React

Increase SSR test timeout and ensure cleanup

Jonny Burger45d59763f71e
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 1036c3ae42..ab7f59d41a 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -181,7 +181,7 @@ jobs:
- name: Cache Turbo
uses: rharkor/[email protected]
- name: Test SSR
- timeout-minutes: 8
+ timeout-minutes: 15
run: |
bun run testssr
- name: Monorepo checks
diff --git a/packages/it-tests/src/ssr/render-frames.test.ts b/packages/it-tests/src/ssr/render-frames.test.ts
index e6c91413d3..aa7011e1fb 100644
--- a/packages/it-tests/src/ssr/render-frames.test.ts
+++ b/packages/it-tests/src/ssr/render-frames.test.ts
@@ -16,61 +16,68 @@ test(
'Legacy SSR way of rendering videos should still work',
async () => {
const puppeteerInstance = await openBrowser('chrome');
- const compositions = await getCompositions({
- serveUrl: exampleBuild,
- puppeteerInstance,
- inputProps: {},
- });
+ let framesDir: string | null = null;
+ try {
+ const compositions = await getCompositions({
+ serveUrl: exampleBuild,
+ puppeteerInstance,
+ inputProps: {},
+ });
- const reactSvg = compositions.find((c) => c.id === '22khz');
+ const reactSvg = compositions.find((c) => c.id === '22khz');
- if (!reactSvg) {
- throw new Error('not found');
- }
+ if (!reactSvg) {
+ throw new Error('not found');
+ }
- const tmpDir = os.tmpdir();
+ const tmpDir = os.tmpdir();
- // We create a temporary directory for storing the frames
- const framesDir = await fs.promises.mkdtemp(
- path.join(os.tmpdir(), 'remotion-'),
- );
+ // We create a temporary directory for storing the frames
+ const createdFramesDir = await fs.promises.mkdtemp(
+ path.join(os.tmpdir(), 'remotion-'),
+ );
+ framesDir = createdFramesDir;
- const outPath = path.join(tmpDir, 'out.mp4');
+ const outPath = path.join(tmpDir, 'out.mp4');
- const {assetsInfo} = await renderFrames({
- composition: reactSvg,
- imageFormat: 'jpeg',
- inputProps: {},
- onFrameUpdate: () => undefined,
- serveUrl: exampleBuild,
- concurrency: null,
- frameRange: [0, 10],
- outputDir: framesDir,
- onStart: () => undefined,
- });
- await stitchFramesToVideo({
- assetsInfo,
- force: true,
- fps: reactSvg.fps,
- height: reactSvg.height,
- outputLocation: outPath,
- width: reactSvg.width,
- codec: 'h264',
- metadata: {Author: 'Lunar'},
- });
- expect(fs.existsSync(outPath)).toBe(true);
- const probe = await RenderInternals.callFf({
- bin: 'ffprobe',
- args: [outPath],
- indent: false,
- logLevel: 'info',
- binariesDirectory: null,
- cancelSignal: undefined,
- });
- expect(probe.stderr).toMatch(/Video: h264/);
+ const {assetsInfo} = await renderFrames({
+ composition: reactSvg,
+ imageFormat: 'jpeg',
+ inputProps: {},
+ onFrameUpdate: () => undefined,
+ serveUrl: exampleBuild,
+ concurrency: null,
+ frameRange: [0, 10],
+ outputDir: createdFramesDir,
+ onStart: () => undefined,
+ });
+ await stitchFramesToVideo({
+ assetsInfo,
+ force: true,
+ fps: reactSvg.fps,
+ height: reactSvg.height,
+ outputLocation: outPath,
+ width: reactSvg.width,
+ codec: 'h264',
+ metadata: {Author: 'Lunar'},
+ });
+ expect(fs.existsSync(outPath)).toBe(true);
+ const probe = await RenderInternals.callFf({
+ bin: 'ffprobe',
+ args: [outPath],
+ indent: false,
+ logLevel: 'info',
+ binariesDirectory: null,
+ cancelSignal: undefined,
+ });
+ expect(probe.stderr).toMatch(/Video: h264/);
+ } finally {
+ if (framesDir !== null) {
+ RenderInternals.deleteDirectory(framesDir);
+ }
- RenderInternals.deleteDirectory(framesDir);
- await puppeteerInstance.close({silent: false});
+ await puppeteerInstance.close({silent: false});
+ }
},
{retry: 3},
);
diff --git a/packages/it-tests/src/ssr/render-still.test.ts b/packages/it-tests/src/ssr/render-still.test.ts
index e14d901f44..1eb1b3e6c4 100644
--- a/packages/it-tests/src/ssr/render-still.test.ts
+++ b/packages/it-tests/src/ssr/render-still.test.ts
@@ -19,30 +19,33 @@ test(
'Render video with browser instance open',
async () => {
const puppeteerInstance = await openBrowser('chrome');
- const compositions = await getCompositions({
- serveUrl: exampleBuild,
- puppeteerInstance,
- inputProps: {},
- });
+ try {
+ const compositions = await getCompositions({
+ serveUrl: exampleBuild,
+ puppeteerInstance,
+ inputProps: {},
+ });
- const reactSvg = compositions.find((c) => c.id === 'react-svg');
+ const reactSvg = compositions.find((c) => c.id === 'react-svg');
- if (!reactSvg) {
- throw new Error('not found');
- }
+ if (!reactSvg) {
+ throw new Error('not found');
+ }
- const tmpDir = os.tmpdir();
+ const tmpDir = os.tmpdir();
- const outPath = path.join(tmpDir, 'out.mp4');
+ const outPath = path.join(tmpDir, 'out.mp4');
- const {buffer} = await renderStill({
- output: outPath,
- serveUrl: exampleBuild,
- composition: reactSvg,
- puppeteerInstance,
- });
- expect(buffer).toBe(null);
- await puppeteerInstance.close({silent: false});
+ const {buffer} = await renderStill({
+ output: outPath,
+ serveUrl: exampleBuild,
+ composition: reactSvg,
+ puppeteerInstance,
+ });
+ expect(buffer).toBe(null);
+ } finally {
+ await puppeteerInstance.close({silent: false});
+ }
},
{retry: 3},
);