🎥 Make videos programmatically with React
ffmpeg + ffprobe command
Jonny Burger9aa1de08194a
diff --git a/packages/cli/src/ffmpeg.ts b/packages/cli/src/ffmpeg.tsnew file mode 100644index 0000000000..bf53b15cc3--- /dev/null+++ b/packages/cli/src/ffmpeg.ts@@ -0,0 +1,17 @@+import {RenderInternals} from '@remotion/renderer';+import {spawnSync} from 'child_process';++export const ffmpegCommand = (_root: string, args: string[]) => {+ spawnSync(RenderInternals.getExecutablePath('ffmpeg'), args, {+ ...RenderInternals.callFfExtraOptions(),+ stdio: 'inherit',+ });+};++export const ffprobeCommand = (_root: string, args: string[]) => {+ const done = spawnSync(RenderInternals.getExecutablePath('ffprobe'), args, {+ ...RenderInternals.callFfExtraOptions(),+ stdio: 'inherit',+ });+ process.exit(done.status as number);+};diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsxindex 462ab3d6c9..e539bff7de 100644--- a/packages/cli/src/index.tsx+++ b/packages/cli/src/index.tsx@@ -7,6 +7,7 @@ import {overrideRemotion} from './config/index';import {determineFinalImageFormat} from './determine-image-format';import {getFileSizeDownloadBar} from './download-progress';import {findEntryPoint} from './entry-point';+import {ffmpegCommand, ffprobeCommand} from './ffmpeg';import {formatBytes} from './format-bytes';import {getCliOptions, getFinalCodec} from './get-cli-options';import {loadConfig} from './get-config-file-name';@@ -62,6 +63,10 @@ export const cli = async () => {await render(remotionRoot, args);} else if (command === 'still') {await still(remotionRoot, args);+ } else if (command === 'ffmpeg') {+ ffmpegCommand(remotionRoot, process.argv.slice(3));+ } else if (command === 'ffprobe') {+ ffprobeCommand(remotionRoot, process.argv.slice(3));} else if (command === 'upgrade') {await upgrade(remotionRoot, parsedCli['package-manager']);} else if (command === VERSIONS_COMMAND) {diff --git a/packages/renderer/src/call-ffmpeg.ts b/packages/renderer/src/call-ffmpeg.tsindex 8783760df5..271d6c58c7 100644--- a/packages/renderer/src/call-ffmpeg.ts+++ b/packages/renderer/src/call-ffmpeg.ts@@ -5,10 +5,11 @@ import {truthy} from './truthy';export const callFfExtraOptions = () => {return {- cwd: getExecutablePath('ffmpeg-cwd'),env:process.platform === 'darwin'- ? undefined+ ? {+ DYLD_LIBRARY_PATH: path.join(getExecutablePath('ffmpeg-cwd')),+ }: {LD_LIBRARY_PATH: path.join(getExecutablePath('ffmpeg-cwd'), 'lib'),},diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex 7e6f9da924..43584083e0 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -4,7 +4,7 @@ import {cleanDownloadMap, makeDownloadMap} from './assets/download-map';import {getDefaultAudioCodec, validAudioCodecs} from './audio-codec';import {DEFAULT_BROWSER} from './browser';import {DEFAULT_TIMEOUT} from './browser/TimeoutSettings';-import {callFf} from './call-ffmpeg';+import {callFf, callFfExtraOptions} from './call-ffmpeg';import {canUseParallelEncoding} from './can-use-parallel-encoding';import {checkNodeVersionAndWarnAboutRosetta} from './check-apple-silicon';import {DEFAULT_CODEC, validCodecs} from './codec';@@ -156,6 +156,7 @@ export const RenderInternals = {defaultCodecsForFileExtension,getExecutablePath,callFf,+ callFfExtraOptions,};// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)