diff options
author | Chocobozzz <me@florianbigard.com> | 2021-03-11 09:51:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-03-24 18:18:40 +0100 |
commit | ae71acca14e9420646ca7655e64eb9adc13e3006 (patch) | |
tree | 97e1e4bd94ecfbabc9b99fa5670b72440db82890 /server/helpers/ffmpeg-utils.ts | |
parent | db8b2f56c014a3fa207501f74e0bb5088ea41719 (diff) | |
download | PeerTube-ae71acca14e9420646ca7655e64eb9adc13e3006.tar.gz PeerTube-ae71acca14e9420646ca7655e64eb9adc13e3006.tar.zst PeerTube-ae71acca14e9420646ca7655e64eb9adc13e3006.zip |
Check ffmepg version on startup
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 21 |
1 files changed, 20 insertions, 1 deletions
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' | |||
5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' | 5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' |
6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos' | 6 | import { AvailableEncoders, EncoderOptionsBuilder, EncoderProfile, VideoResolution } from '../../shared/models/videos' |
7 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
8 | import { promisify0 } from './core-utils' | 8 | import { execPromise, promisify0 } from './core-utils' |
9 | import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' | 9 | import { computeFPS, getAudioStream, getVideoFileFPS } from './ffprobe-utils' |
10 | import { processImage } from './image-utils' | 10 | import { processImage } from './image-utils' |
11 | import { logger } from './logger' | 11 | import { logger } from './logger' |
@@ -649,6 +649,24 @@ function getFFmpeg (input: string, type: 'live' | 'vod') { | |||
649 | return command | 649 | return command |
650 | } | 650 | } |
651 | 651 | ||
652 | function getFFmpegVersion () { | ||
653 | return new Promise<string>((res, rej) => { | ||
654 | (ffmpeg() as any)._getFfmpegPath((err, ffmpegPath) => { | ||
655 | if (err) return rej(err) | ||
656 | if (!ffmpegPath) return rej(new Error('Could not find ffmpeg path')) | ||
657 | |||
658 | return execPromise(`${ffmpegPath} -version`) | ||
659 | .then(stdout => { | ||
660 | const parsed = stdout.match(/ffmpeg version .(\d+\.\d+\.\d+)/) | ||
661 | if (!parsed || !parsed[1]) return rej(new Error(`Could not find ffmpeg version in ${stdout}`)) | ||
662 | |||
663 | return res(parsed[1]) | ||
664 | }) | ||
665 | .catch(err => rej(err)) | ||
666 | }) | ||
667 | }) | ||
668 | } | ||
669 | |||
652 | async function runCommand (options: { | 670 | async function runCommand (options: { |
653 | command: ffmpeg.FfmpegCommand | 671 | command: ffmpeg.FfmpegCommand |
654 | silent?: boolean // false | 672 | silent?: boolean // false |
@@ -695,6 +713,7 @@ export { | |||
695 | TranscodeOptionsType, | 713 | TranscodeOptionsType, |
696 | transcode, | 714 | transcode, |
697 | runCommand, | 715 | runCommand, |
716 | getFFmpegVersion, | ||
698 | 717 | ||
699 | resetSupportedEncoders, | 718 | resetSupportedEncoders, |
700 | 719 | ||