Skip to content

🎥 Make videos programmatically with React

cli commands

Jonny Burgerb658ee890940
diff --git a/packages/cli/src/deps.ts b/packages/cli/src/deps.ts
new file mode 100644
index 0000000000..f4caef6bbc
--- /dev/null
+++ b/packages/cli/src/deps.ts
@@ -0,0 +1,40 @@
+import {ensureFfmpeg, ensureFfprobe} from '@remotion/renderer';
+import {Log} from './log';
+
+export const INSTALL_COMMAND = 'install' as const;
+
+export const installCommand = async (remotionRoot: string, args: string[]) => {
+ const firstArg = args[0];
+ if (firstArg === 'ffmpeg') {
+ const {wasAlreadyInstalled} = await ensureFfmpeg({remotionRoot});
+ if (wasAlreadyInstalled) {
+ Log.info('FFmpeg is already installed');
+ } else {
+ Log.info('Successfully installed FFmpeg');
+ }
+
+ return;
+ }
+
+ if (firstArg === 'ffprobe') {
+ const {wasAlreadyInstalled} = await ensureFfprobe({remotionRoot});
+ if (wasAlreadyInstalled) {
+ Log.info('FFmpeg is already installed');
+ } else {
+ Log.info('Successfully installed FFmpeg');
+ }
+
+ return;
+ }
+
+ Log.error(
+ 'Please specify either "ffmpeg" or "ffprobe" as the first argument to the install command'
+ );
+ Log.error();
+
+ Log.info('Example Usage: ');
+ Log.info(' remotion install ffmpeg');
+ Log.info(' remotion install ffprobe');
+
+ process.exit(1);
+};
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 8d31c2d1da..a3ac976e15 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -4,6 +4,7 @@ import {benchmarkCommand} from './benchmark';
import {chalk} from './chalk';
import {listCompositionsCommand} from './compositions';
import {overrideRemotion} from './config/index';
+import {installCommand, INSTALL_COMMAND} from './deps';
import {determineFinalImageFormat} from './determine-image-format';
import {getFileSizeDownloadBar} from './download-progress';
import {findEntryPoint} from './entry-point';
@@ -64,6 +65,8 @@ export const cli = async () => {
await upgrade(remotionRoot, parsedCli['package-manager']);
} else if (command === VERSIONS_COMMAND) {
await versionsCommand(remotionRoot);
+ } else if (command === INSTALL_COMMAND) {
+ await installCommand(remotionRoot, args);
} else if (command === 'benchmark') {
await benchmarkCommand(remotionRoot, args);
} else if (command === 'help') {
diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.ts
index 2543679409..97720484bd 100644
--- a/packages/cli/src/print-help.ts
+++ b/packages/cli/src/print-help.ts
@@ -1,4 +1,5 @@
import {chalk} from './chalk';
+import {INSTALL_COMMAND} from './deps';
import {Log} from './log';
import {VERSIONS_COMMAND} from './versions';
@@ -77,6 +78,9 @@ export const printHelp = () => {
chalk.gray('Prints and validates versions of all Remotion packages.')
);
Log.info();
+ Log.info(`remotion ${INSTALL_COMMAND} <ffmpeg|ffprobe>`);
+ Log.info(chalk.gray('Installs dependencies of Remotion'));
+ Log.info();
Log.info('remotion upgrade');
Log.info(chalk.gray('Ensure Remotion is on the newest version.'));
printFlags([