aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker-before-init.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-23 16:23:52 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 10:07:51 +0100
commit9252a33d115bba85adcfbc18ab3725924642871c (patch)
tree94365b67fc25cb0d9ce046a820d07344742179f6 /server/initializers/checker-before-init.ts
parentdaf6e4801052d3ca6be2fafd20bae2323b1ce175 (diff)
downloadPeerTube-9252a33d115bba85adcfbc18ab3725924642871c.tar.gz
PeerTube-9252a33d115bba85adcfbc18ab3725924642871c.tar.zst
PeerTube-9252a33d115bba85adcfbc18ab3725924642871c.zip
Export encoders options in a dedicated struct
Diffstat (limited to 'server/initializers/checker-before-init.ts')
-rw-r--r--server/initializers/checker-before-init.ts29
1 files changed, 18 insertions, 11 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 93b71a242..4ffd6fad9 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -82,6 +82,8 @@ function checkMissedConfig () {
82async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { 82async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
83 if (CONFIG.TRANSCODING.ENABLED === false) return undefined 83 if (CONFIG.TRANSCODING.ENABLED === false) return undefined
84 84
85 checkFFmpegEncoders()
86
85 const Ffmpeg = require('fluent-ffmpeg') 87 const Ffmpeg = require('fluent-ffmpeg')
86 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) 88 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
87 const codecs = await getAvailableCodecsPromise() 89 const codecs = await getAvailableCodecsPromise()
@@ -100,25 +102,30 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
100 return checkFFmpegEncoders() 102 return checkFFmpegEncoders()
101} 103}
102 104
103// Optional encoders, if present, can be used to improve transcoding 105// Detect supported encoders by ffmpeg
104// Here we ask ffmpeg if it detects their presence on the system, so that we can later use them 106let supportedEncoders: Map<string, boolean>
105let supportedOptionalEncoders: Map<string, boolean>
106async function checkFFmpegEncoders (): Promise<Map<string, boolean>> { 107async function checkFFmpegEncoders (): Promise<Map<string, boolean>> {
107 if (supportedOptionalEncoders !== undefined) { 108 if (supportedEncoders !== undefined) {
108 return supportedOptionalEncoders 109 return supportedEncoders
109 } 110 }
110 111
111 const Ffmpeg = require('fluent-ffmpeg') 112 const Ffmpeg = require('fluent-ffmpeg')
112 const getAvailableEncodersPromise = promisify0(Ffmpeg.getAvailableEncoders) 113 const getAvailableEncodersPromise = promisify0(Ffmpeg.getAvailableEncoders)
113 const encoders = await getAvailableEncodersPromise() 114 const availableEncoders = await getAvailableEncodersPromise()
114 const optionalEncoders = [ 'libfdk_aac' ] 115
115 supportedOptionalEncoders = new Map<string, boolean>() 116 const searchEncoders = [
117 'aac',
118 'libfdk_aac',
119 'libx264'
120 ]
121
122 supportedEncoders = new Map<string, boolean>()
116 123
117 for (const encoder of optionalEncoders) { 124 for (const searchEncoder of searchEncoders) {
118 supportedOptionalEncoders.set(encoder, encoders[encoder] !== undefined) 125 supportedEncoders.set(searchEncoder, availableEncoders[searchEncoder] !== undefined)
119 } 126 }
120 127
121 return supportedOptionalEncoders 128 return supportedEncoders
122} 129}
123 130
124function checkNodeVersion () { 131function checkNodeVersion () {