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/helpers/ffmpeg-utils.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'server/helpers/ffmpeg-utils.ts') diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 620025966..69cd397b9 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -5,7 +5,7 @@ import { dirname, join } from 'path' import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos' import { CONFIG } from '../initializers/config' -import { promisify0 } from './core-utils' +import { execPromise, promisify0 } from './core-utils' import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' import { processImage } from './image-utils' import { logger } from './logger' @@ -649,6 +649,24 @@ function getFFmpeg (input: string, type: 'live' | 'vod') { return command } +function getFFmpegVersion () { + return new Promise((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: { command: ffmpeg.FfmpegCommand silent?: boolean // false @@ -695,6 +713,7 @@ export { TranscodeOptionsType, transcode, runCommand, + getFFmpegVersion, resetSupportedEncoders, -- cgit v1.2.3