From 2055962c844e557d628d9d0aae9303590c39eab8 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Wed, 2 Aug 2023 23:22:36 +0100 Subject: fix: handle git installation of ffmpeg --- server/server/helpers/core-utils.ts | 14 ++++++++++++-- server/server/initializers/checker-after-init.ts | 9 ++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/server/helpers/core-utils.ts b/server/server/helpers/core-utils.ts index 6dc09d317..9b40ca5be 100644 --- a/server/server/helpers/core-utils.ts +++ b/server/server/helpers/core-utils.ts @@ -183,13 +183,23 @@ function pageToStartAndCount (page: number, itemsPerPage: number) { // --------------------------------------------------------------------------- type SemVersion = { major: number, minor: number, patch: number } + +/** + * Parses a semantic version string into its separate components. + * Fairly lax, and allows for missing or additional segments in the string. + * + * @param s String to parse semantic version from. + * @returns Major, minor, and patch version, or null if string does not follow semantic version conventions. + */ function parseSemVersion (s: string) { - const parsed = s.match(/^v?(\d+)\.(\d+)\.(\d+)$/i) + const parsed = s.match(/v?(\d+)\.(\d+)(?:\.(\d+))?/i) + + if (!parsed) return null return { major: parseInt(parsed[1]), minor: parseInt(parsed[2]), - patch: parseInt(parsed[3]) + patch: parsed[3] ? parseInt(parsed[3]) : 0 } as SemVersion } diff --git a/server/server/initializers/checker-after-init.ts b/server/server/initializers/checker-after-init.ts index afcf6176b..5e7e513f1 100644 --- a/server/server/initializers/checker-after-init.ts +++ b/server/server/initializers/checker-after-init.ts @@ -78,7 +78,14 @@ async function applicationExist () { async function checkFFmpegVersion () { const version = await getFFmpegVersion() - const { major, minor, patch } = parseSemVersion(version) + const semvar = parseSemVersion(version) + + if (!semvar) { + logger.warn('Your ffmpeg version (%s) does not use semvar. Unable to determine version compatibility.', version) + return + } + + const { major, minor, patch } = semvar if (major < 4 || (major === 4 && minor < 1)) { logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade ffmpeg.', version) -- cgit v1.2.3