From ae71acca14e9420646ca7655e64eb9adc13e3006 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Mar 2021 09:51:08 +0100 Subject: Check ffmepg version on startup --- server/initializers/checker-after-init.ts | 27 +++++++++++++++++++-------- server/initializers/checker-before-init.ts | 5 ++--- 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 2b00e2047..a93c8b7fd 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -1,16 +1,17 @@ import * as config from 'config' -import { isProdInstance, isTestInstance } from '../helpers/core-utils' -import { UserModel } from '../models/account/user' -import { getServerActor, ApplicationModel } from '../models/application/application' -import { OAuthClientModel } from '../models/oauth/oauth-client' +import { uniq } from 'lodash' import { URL } from 'url' -import { CONFIG, isEmailEnabled } from './config' -import { logger } from '../helpers/logger' +import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' +import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' import { RecentlyAddedStrategy } from '../../shared/models/redundancy' +import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils' import { isArray } from '../helpers/custom-validators/misc' -import { uniq } from 'lodash' +import { logger } from '../helpers/logger' +import { UserModel } from '../models/account/user' +import { ApplicationModel, getServerActor } from '../models/application/application' +import { OAuthClientModel } from '../models/oauth/oauth-client' +import { CONFIG, isEmailEnabled } from './config' import { WEBSERVER } from './constants' -import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' async function checkActivityPubUrls () { const actor = await getServerActor() @@ -176,11 +177,21 @@ async function applicationExist () { return totalApplication !== 0 } +async function checkFFmpegVersion () { + const version = await getFFmpegVersion() + const { major, minor } = parseSemVersion(version) + + if (major < 4 || (major === 4 && minor < 1)) { + logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade.', version) + } +} + // --------------------------------------------------------------------------- export { checkConfig, clientsExist, + checkFFmpegVersion, usersExist, applicationExist, checkActivityPubUrls diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 565e0d1fa..65a019ca6 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -1,5 +1,5 @@ import * as config from 'config' -import { promisify0 } from '../helpers/core-utils' +import { parseSemVersion, promisify0 } from '../helpers/core-utils' import { logger } from '../helpers/logger' // ONLY USE CORE MODULES IN THIS FILE! @@ -102,8 +102,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { function checkNodeVersion () { const v = process.version - const majorString = v.split('.')[0].replace('v', '') - const major = parseInt(majorString, 10) + const { major } = parseSemVersion(v) logger.debug('Checking NodeJS version %s.', v) -- cgit v1.2.3