aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-05 17:15:21 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-05 17:15:21 +0200
commite5b885390557dd61d64ca3e0db5f33dd602518f2 (patch)
treec6bc6076a43d63a3634234ef3f249907bf2eece1 /server
parentd33242b047c68ae81c9657d05893d1838f1b1c89 (diff)
downloadPeerTube-e5b885390557dd61d64ca3e0db5f33dd602518f2.tar.gz
PeerTube-e5b885390557dd61d64ca3e0db5f33dd602518f2.tar.zst
PeerTube-e5b885390557dd61d64ca3e0db5f33dd602518f2.zip
Server: check ffmpeg at startup
Diffstat (limited to 'server')
-rw-r--r--server/initializers/checker.js25
1 files changed, 25 insertions, 0 deletions
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 @@
2 2
3const config = require('config') 3const config = require('config')
4 4
5const constants = require('./constants')
5const db = require('./database') 6const db = require('./database')
6 7
7const checker = { 8const checker = {
8 checkConfig, 9 checkConfig,
10 checkFFmpeg,
9 checkMissedConfig, 11 checkMissedConfig,
10 clientsExist, 12 clientsExist,
11 usersExist 13 usersExist
@@ -42,6 +44,29 @@ function checkMissedConfig () {
42 return miss 44 return miss
43} 45}
44 46
47// Check the available codecs
48function checkFFmpeg (callback) {
49 const Ffmpeg = require('fluent-ffmpeg')
50
51 Ffmpeg.getAvailableCodecs(function (err, codecs) {
52 if (err) return callback(err)
53 if (constants.CONFIG.TRANSCODING.ENABLED === false) return callback(null)
54
55 const canEncode = [ 'libx264' ]
56 canEncode.forEach(function (codec) {
57 if (codecs[codec] === undefined) {
58 return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.'))
59 }
60
61 if (codecs[codec].canEncode !== true) {
62 return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg'))
63 }
64 })
65
66 return callback(null)
67 })
68}
69
45function clientsExist (callback) { 70function clientsExist (callback) {
46 db.OAuthClient.countTotal(function (err, totalClients) { 71 db.OAuthClient.countTotal(function (err, totalClients) {
47 if (err) return callback(err) 72 if (err) return callback(err)