Server: check ffmpeg at startup

pull/71/head
Chocobozzz 2017-05-05 17:15:21 +02:00
parent d33242b047
commit e5b8853905
1 changed files with 25 additions and 0 deletions

View File

@ -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)