From: Chocobozzz Date: Fri, 5 May 2017 15:15:21 +0000 (+0200) Subject: Server: check ffmpeg at startup X-Git-Tag: v0.0.1-alpha~430 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e5b885390557dd61d64ca3e0db5f33dd602518f2;p=oweals%2Fpeertube.git Server: check ffmpeg at startup --- diff --git a/server/initializers/checker.js b/server/initializers/checker.js index a3727563a..aa8dea4bf 100644 --- a/server/initializers/checker.js +++ b/server/initializers/checker.js @@ -2,10 +2,12 @@ const config = require('config') +const constants = require('./constants') const db = require('./database') const checker = { checkConfig, + checkFFmpeg, checkMissedConfig, clientsExist, usersExist @@ -42,6 +44,29 @@ function checkMissedConfig () { return miss } +// Check the available codecs +function checkFFmpeg (callback) { + const Ffmpeg = require('fluent-ffmpeg') + + Ffmpeg.getAvailableCodecs(function (err, codecs) { + if (err) return callback(err) + if (constants.CONFIG.TRANSCODING.ENABLED === false) return callback(null) + + const canEncode = [ 'libx264' ] + canEncode.forEach(function (codec) { + if (codecs[codec] === undefined) { + return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.')) + } + + if (codecs[codec].canEncode !== true) { + return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg')) + } + }) + + return callback(null) + }) +} + function clientsExist (callback) { db.OAuthClient.countTotal(function (err, totalClients) { if (err) return callback(err)