diff options
author | Seth Falco <seth@falco.fun> | 2023-08-02 23:22:36 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-08-18 10:17:16 +0200 |
commit | 2055962c844e557d628d9d0aae9303590c39eab8 (patch) | |
tree | e1ead9fc49f6b70e51e3728485d5c6b6c2d7fba9 /packages/ffmpeg | |
parent | 8e4fba97b26090e0c77ee9591058cd34ef9d2f55 (diff) | |
download | PeerTube-2055962c844e557d628d9d0aae9303590c39eab8.tar.gz PeerTube-2055962c844e557d628d9d0aae9303590c39eab8.tar.zst PeerTube-2055962c844e557d628d9d0aae9303590c39eab8.zip |
fix: handle git installation of ffmpeg
Diffstat (limited to 'packages/ffmpeg')
-rw-r--r-- | packages/ffmpeg/src/ffmpeg-version.ts | 13 |
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 @@ | |||
1 | import { exec } from 'child_process' | 1 | import { exec } from 'child_process' |
2 | import ffmpeg from 'fluent-ffmpeg' | 2 | import 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 | */ | ||
4 | export function getFFmpegVersion () { | 7 | export 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 | }) |