aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-28 15:52:44 +0100
committerChocobozzz <me@florianbigard.com>2021-01-28 15:55:39 +0100
commit1896bca09e088b0da9d5e845407ecebae330618c (patch)
tree56041c445c0cd49aca536d0fd6b586730f4d341e /server/initializers
parent529b37527cff5203a0689a15ce73dcee6e1eece2 (diff)
downloadPeerTube-1896bca09e088b0da9d5e845407ecebae330618c.tar.gz
PeerTube-1896bca09e088b0da9d5e845407ecebae330618c.tar.zst
PeerTube-1896bca09e088b0da9d5e845407ecebae330618c.zip
Support transcoding options/encoders by plugins
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-before-init.ts29
-rw-r--r--server/initializers/config.ts2
2 files changed, 2 insertions, 29 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 7945e8586..9c4e0048a 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -97,34 +97,6 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
97 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') 97 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg')
98 } 98 }
99 } 99 }
100
101 return checkFFmpegEncoders()
102}
103
104// Detect supported encoders by ffmpeg
105let supportedEncoders: Map<string, boolean>
106async function checkFFmpegEncoders (): Promise<Map<string, boolean>> {
107 if (supportedEncoders !== undefined) {
108 return supportedEncoders
109 }
110
111 const Ffmpeg = require('fluent-ffmpeg')
112 const getAvailableEncodersPromise = promisify0(Ffmpeg.getAvailableEncoders)
113 const availableEncoders = await getAvailableEncodersPromise()
114
115 const searchEncoders = [
116 'aac',
117 'libfdk_aac',
118 'libx264'
119 ]
120
121 supportedEncoders = new Map<string, boolean>()
122
123 for (const searchEncoder of searchEncoders) {
124 supportedEncoders.set(searchEncoder, availableEncoders[searchEncoder] !== undefined)
125 }
126
127 return supportedEncoders
128} 100}
129 101
130function checkNodeVersion () { 102function checkNodeVersion () {
@@ -143,7 +115,6 @@ function checkNodeVersion () {
143 115
144export { 116export {
145 checkFFmpeg, 117 checkFFmpeg,
146 checkFFmpegEncoders,
147 checkMissedConfig, 118 checkMissedConfig,
148 checkNodeVersion 119 checkNodeVersion
149} 120}
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index fc4a8b709..7322b89e2 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -188,6 +188,7 @@ const CONFIG = {
188 get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') }, 188 get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
189 get ALLOW_AUDIO_FILES () { return config.get<boolean>('transcoding.allow_audio_files') }, 189 get ALLOW_AUDIO_FILES () { return config.get<boolean>('transcoding.allow_audio_files') },
190 get THREADS () { return config.get<number>('transcoding.threads') }, 190 get THREADS () { return config.get<number>('transcoding.threads') },
191 get PROFILE () { return config.get<string>('transcoding.profile') },
191 RESOLUTIONS: { 192 RESOLUTIONS: {
192 get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') }, 193 get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') },
193 get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') }, 194 get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
@@ -221,6 +222,7 @@ const CONFIG = {
221 TRANSCODING: { 222 TRANSCODING: {
222 get ENABLED () { return config.get<boolean>('live.transcoding.enabled') }, 223 get ENABLED () { return config.get<boolean>('live.transcoding.enabled') },
223 get THREADS () { return config.get<number>('live.transcoding.threads') }, 224 get THREADS () { return config.get<number>('live.transcoding.threads') },
225 get PROFILE () { return config.get<string>('live.transcoding.profile') },
224 226
225 RESOLUTIONS: { 227 RESOLUTIONS: {
226 get '240p' () { return config.get<boolean>('live.transcoding.resolutions.240p') }, 228 get '240p' () { return config.get<boolean>('live.transcoding.resolutions.240p') },