mirror of https://github.com/Chocobozzz/PeerTube
Check ffmepg version on startup
parent
db8b2f56c0
commit
ae71acca14
|
@ -44,7 +44,7 @@ checkFFmpeg(CONFIG)
|
||||||
|
|
||||||
checkNodeVersion()
|
checkNodeVersion()
|
||||||
|
|
||||||
import { checkConfig, checkActivityPubUrls } from './server/initializers/checker-after-init'
|
import { checkConfig, checkActivityPubUrls, checkFFmpegVersion } from './server/initializers/checker-after-init'
|
||||||
|
|
||||||
const errorMessage = checkConfig()
|
const errorMessage = checkConfig()
|
||||||
if (errorMessage !== null) {
|
if (errorMessage !== null) {
|
||||||
|
@ -252,6 +252,9 @@ async function startApplication () {
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
checkFFmpegVersion()
|
||||||
|
.catch(err => logger.error('Cannot check ffmpeg version', { err }))
|
||||||
|
|
||||||
// Email initialization
|
// Email initialization
|
||||||
Emailer.Instance.init()
|
Emailer.Instance.init()
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,16 @@ function promisify2<T, U, A> (func: (arg1: T, arg2: U, cb: (err: any, result: A)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseSemVersion (s: string) {
|
||||||
|
const parsed = s.match(/^v?(\d+)\.(\d+)\.(\d+)$/i)
|
||||||
|
|
||||||
|
return {
|
||||||
|
major: parseInt(parsed[1]),
|
||||||
|
minor: parseInt(parsed[2]),
|
||||||
|
patch: parseInt(parsed[3])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const randomBytesPromise = promisify1<number, Buffer>(randomBytes)
|
const randomBytesPromise = promisify1<number, Buffer>(randomBytes)
|
||||||
const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
|
const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
|
||||||
const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
|
const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
|
||||||
|
@ -288,5 +298,7 @@ export {
|
||||||
getPublicKey,
|
getPublicKey,
|
||||||
execPromise2,
|
execPromise2,
|
||||||
execPromise,
|
execPromise,
|
||||||
pipelinePromise
|
pipelinePromise,
|
||||||
|
|
||||||
|
parseSemVersion
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { dirname, join } from 'path'
|
||||||
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
|
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
|
||||||
import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos'
|
import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
import { promisify0 } from './core-utils'
|
import { execPromise, promisify0 } from './core-utils'
|
||||||
import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
|
import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils'
|
||||||
import { processImage } from './image-utils'
|
import { processImage } from './image-utils'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
|
@ -649,6 +649,24 @@ function getFFmpeg (input: string, type: 'live' | 'vod') {
|
||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFFmpegVersion () {
|
||||||
|
return new Promise<string>((res, rej) => {
|
||||||
|
(ffmpeg() as any)._getFfmpegPath((err, ffmpegPath) => {
|
||||||
|
if (err) return rej(err)
|
||||||
|
if (!ffmpegPath) return rej(new Error('Could not find ffmpeg path'))
|
||||||
|
|
||||||
|
return execPromise(`${ffmpegPath} -version`)
|
||||||
|
.then(stdout => {
|
||||||
|
const parsed = stdout.match(/ffmpeg version .(\d+\.\d+\.\d+)/)
|
||||||
|
if (!parsed || !parsed[1]) return rej(new Error(`Could not find ffmpeg version in ${stdout}`))
|
||||||
|
|
||||||
|
return res(parsed[1])
|
||||||
|
})
|
||||||
|
.catch(err => rej(err))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function runCommand (options: {
|
async function runCommand (options: {
|
||||||
command: ffmpeg.FfmpegCommand
|
command: ffmpeg.FfmpegCommand
|
||||||
silent?: boolean // false
|
silent?: boolean // false
|
||||||
|
@ -695,6 +713,7 @@ export {
|
||||||
TranscodeOptionsType,
|
TranscodeOptionsType,
|
||||||
transcode,
|
transcode,
|
||||||
runCommand,
|
runCommand,
|
||||||
|
getFFmpegVersion,
|
||||||
|
|
||||||
resetSupportedEncoders,
|
resetSupportedEncoders,
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import * as config from 'config'
|
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 { URL } from 'url'
|
|
||||||
import { CONFIG, isEmailEnabled } from './config'
|
|
||||||
import { logger } from '../helpers/logger'
|
|
||||||
import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
|
|
||||||
import { isArray } from '../helpers/custom-validators/misc'
|
|
||||||
import { uniq } from 'lodash'
|
import { uniq } from 'lodash'
|
||||||
import { WEBSERVER } from './constants'
|
import { URL } from 'url'
|
||||||
|
import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
|
||||||
import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
|
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 { 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'
|
||||||
|
|
||||||
async function checkActivityPubUrls () {
|
async function checkActivityPubUrls () {
|
||||||
const actor = await getServerActor()
|
const actor = await getServerActor()
|
||||||
|
@ -176,11 +177,21 @@ async function applicationExist () {
|
||||||
return totalApplication !== 0
|
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 {
|
export {
|
||||||
checkConfig,
|
checkConfig,
|
||||||
clientsExist,
|
clientsExist,
|
||||||
|
checkFFmpegVersion,
|
||||||
usersExist,
|
usersExist,
|
||||||
applicationExist,
|
applicationExist,
|
||||||
checkActivityPubUrls
|
checkActivityPubUrls
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as config from 'config'
|
import * as config from 'config'
|
||||||
import { promisify0 } from '../helpers/core-utils'
|
import { parseSemVersion, promisify0 } from '../helpers/core-utils'
|
||||||
import { logger } from '../helpers/logger'
|
import { logger } from '../helpers/logger'
|
||||||
|
|
||||||
// ONLY USE CORE MODULES IN THIS FILE!
|
// ONLY USE CORE MODULES IN THIS FILE!
|
||||||
|
@ -102,8 +102,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
|
||||||
|
|
||||||
function checkNodeVersion () {
|
function checkNodeVersion () {
|
||||||
const v = process.version
|
const v = process.version
|
||||||
const majorString = v.split('.')[0].replace('v', '')
|
const { major } = parseSemVersion(v)
|
||||||
const major = parseInt(majorString, 10)
|
|
||||||
|
|
||||||
logger.debug('Checking NodeJS version %s.', v)
|
logger.debug('Checking NodeJS version %s.', v)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue