aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-05-21 13:14:29 +0200
committerChocobozzz <me@florianbigard.com>2018-08-01 10:57:13 +0200
commit4176e227cb18c40e13f30f4634d128cc3169e9d4 (patch)
treebf31f4abb7352d309a4d19311b78013162699d6f /server/initializers
parente80687c458065500e5f1d72fdedd2906c0d58b1a (diff)
downloadPeerTube-4176e227cb18c40e13f30f4634d128cc3169e9d4.tar.gz
PeerTube-4176e227cb18c40e13f30f4634d128cc3169e9d4.tar.zst
PeerTube-4176e227cb18c40e13f30f4634d128cc3169e9d4.zip
Fixing #626 with ffmpeg's low default audio bitrate
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker.ts28
1 files changed, 26 insertions, 2 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 270cbf649..f1c2e80a9 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -84,11 +84,11 @@ function checkMissedConfig () {
84async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { 84async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
85 const Ffmpeg = require('fluent-ffmpeg') 85 const Ffmpeg = require('fluent-ffmpeg')
86 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) 86 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
87
88 const codecs = await getAvailableCodecsPromise() 87 const codecs = await getAvailableCodecsPromise()
88 const canEncode = [ 'libx264' ]
89
89 if (CONFIG.TRANSCODING.ENABLED === false) return undefined 90 if (CONFIG.TRANSCODING.ENABLED === false) return undefined
90 91
91 const canEncode = [ 'libx264' ]
92 for (const codec of canEncode) { 92 for (const codec of canEncode) {
93 if (codecs[codec] === undefined) { 93 if (codecs[codec] === undefined) {
94 throw new Error('Unknown codec ' + codec + ' in FFmpeg.') 94 throw new Error('Unknown codec ' + codec + ' in FFmpeg.')
@@ -98,6 +98,29 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
98 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') 98 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg')
99 } 99 }
100 } 100 }
101
102 checkFFmpegEncoders()
103}
104
105// Optional encoders, if present, can be used to improve transcoding
106// Here we ask ffmpeg if it detects their presence on the system, so that we can later use them
107let supportedOptionalEncoders: Map<string, boolean>
108async function checkFFmpegEncoders (): Promise<Map<string, boolean>> {
109 if (supportedOptionalEncoders !== undefined) {
110 return supportedOptionalEncoders
111 }
112
113 const Ffmpeg = require('fluent-ffmpeg')
114 const getAvailableEncodersPromise = promisify0(Ffmpeg.getAvailableEncoders)
115 const encoders = await getAvailableEncodersPromise()
116 const optionalEncoders = [ 'libfdk_aac' ]
117 supportedOptionalEncoders = new Map<string, boolean>()
118
119 for (const encoder of optionalEncoders) {
120 supportedOptionalEncoders.set(encoder,
121 encoders[encoder] !== undefined
122 )
123 }
101} 124}
102 125
103// We get db by param to not import it in this file (import orders) 126// We get db by param to not import it in this file (import orders)
@@ -126,6 +149,7 @@ async function applicationExist () {
126export { 149export {
127 checkConfig, 150 checkConfig,
128 checkFFmpeg, 151 checkFFmpeg,
152 checkFFmpegEncoders,
129 checkMissedConfig, 153 checkMissedConfig,
130 clientsExist, 154 clientsExist,
131 usersExist, 155 usersExist,