aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/ffmpeg
diff options
context:
space:
mode:
Diffstat (limited to 'packages/ffmpeg')
-rw-r--r--packages/ffmpeg/src/ffmpeg-version.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/packages/ffmpeg/src/ffmpeg-version.ts b/packages/ffmpeg/src/ffmpeg-version.ts
index 41d9b2d89..f737bc254 100644
--- a/packages/ffmpeg/src/ffmpeg-version.ts
+++ b/packages/ffmpeg/src/ffmpeg-version.ts
@@ -1,6 +1,9 @@
1import { exec } from 'child_process' 1import { exec } from 'child_process'
2import ffmpeg from 'fluent-ffmpeg' 2import ffmpeg from 'fluent-ffmpeg'
3 3
4/**
5 * @returns FFmpeg version string. Usually a semver string, but may vary when depending on installation method.
6 */
4export function getFFmpegVersion () { 7export function getFFmpegVersion () {
5 return new Promise<string>((res, rej) => { 8 return new Promise<string>((res, rej) => {
6 (ffmpeg() as any)._getFfmpegPath((err, ffmpegPath) => { 9 (ffmpeg() as any)._getFfmpegPath((err, ffmpegPath) => {
@@ -10,14 +13,10 @@ export function getFFmpegVersion () {
10 return exec(`${ffmpegPath} -version`, (err, stdout) => { 13 return exec(`${ffmpegPath} -version`, (err, stdout) => {
11 if (err) return rej(err) 14 if (err) return rej(err)
12 15
13 const parsed = stdout.match(/ffmpeg version .?(\d+\.\d+(\.\d+)?)/) 16 const parsed = stdout.match(/(?<=ffmpeg version )[a-zA-Z\d.-]+/)
14 if (!parsed?.[1]) return rej(new Error(`Could not find ffmpeg version in ${stdout}`)) 17 if (!parsed) return rej(new Error(`Could not find ffmpeg version in ${stdout}`))
15 18
16 // Fix ffmpeg version that does not include patch version (4.4 for example) 19 res(parsed[0])
17 let version = parsed[1]
18 if (version.match(/^\d+\.\d+$/)) {
19 version += '.0'
20 }
21 }) 20 })
22 }) 21 })
23 }) 22 })