Skip to content

🎥 Make videos programmatically with React

SSR tests

Jonny Burger4db902ef5776
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 92ef2eff29..d389aeb265 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -35,6 +35,36 @@ jobs:
run: |
pnpm build
pnpm run testlambda
+ ssr-tests:
+ runs-on: ubuntu-latest
+ name: Lambda integration
+ steps:
+ - uses: actions/checkout@main
+ - uses: actions/setup-node@v2
+ with:
+ node-version: ${{ matrix.node_version }}
+ - uses: Iamshankhadeep/[email protected]
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ version: ${{ matrix.versionffmpeg_version }}
+
+ - name: Cache .pnpm-store
+ uses: actions/cache@v1
+ with:
+ path: ~/.pnpm-store
+ key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
+
+ - name: Install pnpm
+ run: curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
+ shell: bash
+
+ - name: Install
+ run: pnpm install --frozen-lockfile
+
+ - name: Test
+ run: |
+ pnpm build
+ pnpm run testssr
build:
name: Build Node ${{ matrix.node_version }} - ffmpeg ${{ matrix.ffmpeg_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
diff --git a/package.json b/package.json
index 7537b5b157..c1e58eab27 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"scripts": {
"test": "cd packages/core && npm test && cd ../babel-loader && npm test && cd ../bundler && npm test && cd ../cli && npm test && cd ../eslint-plugin && npm test && cd ../gif && npm test && cd ../lambda && npm test && cd ../media-utils && npm test && cd ../player && npm test && cd ../renderer && npm test && cd ../three && npm test && cd ../.. && npx jest --runInBand --root-dir=tests/integration",
"testlambda": "npx jest --runInBand --root-dir=tests/lambda --setup-files=../../packages/lambda/src/test/setup.ts",
+ "testssr": "npx jest --runInBand --root-dir=tests/ssr --setup-files=../../packages/lambda/src/test/setup.ts",
"build": "pnpm run build --recursive && lerna bootstrap",
"watch": "pnpm run watch --recursive --stream --parallel",
"postinstall": "lerna bootstrap",
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index e26817308b..e0a19f866d 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -218,12 +218,8 @@ export const getCliOptions = async (options: {
const browserExecutable = Internals.getBrowserExecutable();
const ffmpegExecutable = Internals.getCustomFfmpegExecutable();
- const isAudioOnly = Internals.isAudioCodec(codec);
- const parallelEncoding = !shouldOutputImageSequence && !isAudioOnly;
-
return {
parallelism: Internals.getConcurrency(),
- parallelEncoding,
frameRange,
shouldOutputImageSequence,
codec,
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 2594622b52..1329cfd4a9 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -49,7 +49,6 @@ export const render = async () => {
imageFormat,
browserExecutable,
ffmpegExecutable,
- parallelEncoding,
} = await getCliOptions({isLambda: false, type: 'series'});
if (!absoluteOutputFile) {
@@ -234,7 +233,6 @@ export const render = async () => {
onStart: ({frameCount}) => {
totalFrames = frameCount;
},
- parallelEncoding,
});
Log.info();
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index 974c9497c3..fdbc98964b 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -137,7 +137,6 @@ const renderHandler = async (
},
overwrite: false,
- parallelEncoding: true,
});
const endRendered = Date.now();
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 6976a67476..71c2d5cf9f 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -19,6 +19,7 @@ import {OnStartData} from './types';
import {OnDownload} from './assets/download-and-map-assets-to-file';
import {tmpDir} from './tmp-dir';
import {getFileExtensionFromCodec} from './get-extension-from-codec';
+import {isAudioCodec} from 'remotion/src/is-audio-codec';
export type RenderMediaOnDownload = (src: string) => void;
@@ -35,7 +36,6 @@ export type RenderMediaOnProgress = (progress: {
export type RenderMediaOptions = {
proResProfile: ProResProfile | undefined;
parallelism: number | null;
- parallelEncoding: boolean;
crf: number | null;
outputDir: string;
config: TCompMetadata;
@@ -63,7 +63,6 @@ export type RenderMediaOptions = {
export const renderMedia = async ({
parallelism,
proResProfile,
- parallelEncoding,
crf,
outputDir,
config,
@@ -95,10 +94,13 @@ export const renderMedia = async ({
let encodedDoneIn: number | null = null;
const renderStart = Date.now();
const tmpdir = tmpDir('pre-encode');
- const preEncodedFileLocation = path.join(
- tmpdir,
- 'pre-encode.' + getFileExtensionFromCodec(codec, 'chunk')
- );
+ const parallelEncoding = isAudioCodec(codec);
+ const preEncodedFileLocation = parallelEncoding
+ ? path.join(
+ tmpdir,
+ 'pre-encode.' + getFileExtensionFromCodec(codec, 'chunk')
+ )
+ : null;
try {
const callUpdate = () => {
@@ -111,7 +113,7 @@ export const renderMedia = async ({
});
};
- if (parallelEncoding) {
+ if (preEncodedFileLocation) {
if (typeof crf !== 'number') {
throw new TypeError('CRF is unexpectedly not a number');
}
@@ -219,7 +221,10 @@ export const renderMedia = async ({
// TODO: Cleanup
await closeBrowserPromise;
} finally {
- if (fs.existsSync(preEncodedFileLocation)) {
+ if (
+ preEncodedFileLocation !== null &&
+ fs.existsSync(preEncodedFileLocation)
+ ) {
fs.unlinkSync(preEncodedFileLocation);
}
}
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts
index a17157fdb4..d30164f286 100644
--- a/packages/renderer/src/stitcher.ts
+++ b/packages/renderer/src/stitcher.ts
@@ -42,7 +42,7 @@ export type StitcherOptions = {
proResProfile?: ProResProfile;
verbose?: boolean;
parallelEncoding?: boolean;
- preEncodedFileLocation?: string;
+ preEncodedFileLocation?: string | null;
ffmpegExecutable?: FfmpegExecutable;
};
diff --git a/tests/integration/render-video.test.ts b/tests/ssr/render-media.test.ts
similarity index 97%
rename from tests/integration/render-video.test.ts
rename to tests/ssr/render-media.test.ts
index e96679117a..5a919f7b05 100644
--- a/tests/integration/render-video.test.ts
+++ b/tests/ssr/render-media.test.ts
@@ -39,7 +39,6 @@ test("Render video", async () => {
openedBrowser: browserInstance,
outputDir: tmpDir,
overwrite: true,
- parallelEncoding: true,
parallelism: null,
quality: undefined,
});