diff options
Diffstat (limited to 'server/initializers/checker-before-init.ts')
-rw-r--r-- | server/initializers/checker-before-init.ts | 29 |
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 () { | |||
82 | async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { | 82 | async 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 | 106 | let supportedEncoders: Map<string, boolean> |
105 | let supportedOptionalEncoders: Map<string, boolean> | ||
106 | async function checkFFmpegEncoders (): Promise<Map<string, boolean>> { | 107 | async 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 | ||
124 | function checkNodeVersion () { | 131 | function checkNodeVersion () { |