🎥 Make videos programmatically with React
add test and edge case of rendering audio with no audio
Jonny Burgerba9e5f28eee6
diff --git a/packages/cli/src/user-passed-output-location.ts b/packages/cli/src/user-passed-output-location.tsindex a93d3683d1..e0c00567ba 100644--- a/packages/cli/src/user-passed-output-location.ts+++ b/packages/cli/src/user-passed-output-location.ts@@ -1,12 +1,11 @@-import minimist from 'minimist';+import {parsedCli} from './parse-command-line';export const getUserPassedOutputLocation = () => {- const args = minimist(process.argv.slice(2));- if (!args._[3]) {+ if (!parsedCli._[3]) {console.log('Pass an extra argument <output-filename>.');process.exit(1);}- const filename = args._[3];+ const filename = parsedCli._[3];return filename;};diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.tsindex c712c3cc7b..fc8d1a4da2 100644--- a/packages/renderer/src/stitcher.ts+++ b/packages/renderer/src/stitcher.ts@@ -97,6 +97,11 @@ export const stitchFramesToVideo = async (options: {const assetPositions = calculateAssetPositions(fileUrlAssets);const assetPaths = assetPositions.map((asset) => resolveAssetSrc(asset.src));+ if (isAudioOnly && assetPaths.length === 0) {+ throw new Error(+ `Cannot render - you are trying to generate an audio file (${codec}) but your composition doesn't contain any audio.`+ );+ }const assetAudioDetails = await getAssetAudioDetails({assetPaths,parallelism: options.parallelism,diff --git a/tests/rendering.test.ts b/tests/rendering.test.tsindex 4e27cc0c52..a73d924308 100644--- a/tests/rendering.test.ts+++ b/tests/rendering.test.ts@@ -257,3 +257,19 @@ test("Should render a video with GIFs", async () => {recursive: true,});});++test("Should fail to render an audio file that doesn't have any audio inputs", async () => {+ const out = outputPath.replace(".mp4", ".mp3");+ const task = await execa(+ "npx",+ ["remotion", "render", "src/index.tsx", "ten-frame-tester", out],+ {+ cwd: "packages/example",+ reject: false,+ }+ );+ expect(task.exitCode).toBe(process.platform === "win32" ? 0 : 1);+ expect(task.stderr).toContain(+ "Cannot render - you are trying to generate an audio file (mp3) but your composition doesn't contain any audio."+ );+});