aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r--server/helpers/ffmpeg-utils.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index f8299c36f..8936005e0 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -236,7 +236,7 @@ namespace audio {
236 } 236 }
237 237
238 export namespace bitrate { 238 export namespace bitrate {
239 export const baseKbitrate = 384 239 const baseKbitrate = 384
240 240
241 const toBits = (kbits: number): number => { return kbits * 8000 } 241 const toBits = (kbits: number): number => { return kbits * 8000 }
242 242
@@ -274,7 +274,6 @@ namespace audio {
274 * See https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_vbr 274 * See https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_vbr
275 */ 275 */
276async function standard (_ffmpeg) { 276async function standard (_ffmpeg) {
277 let _bitrate = audio.bitrate.baseKbitrate
278 let localFfmpeg = _ffmpeg 277 let localFfmpeg = _ffmpeg
279 .format('mp4') 278 .format('mp4')
280 .videoCodec('libx264') 279 .videoCodec('libx264')
@@ -289,15 +288,6 @@ async function standard (_ffmpeg) {
289 return localFfmpeg.noAudio() 288 return localFfmpeg.noAudio()
290 } 289 }
291 290
292 // we try to reduce the ceiling bitrate by making rough correspondances of bitrates
293 // of course this is far from perfect, but it might save some space in the end
294 if (audio.bitrate[_audio.audioStream['codec_name']]) {
295 _bitrate = audio.bitrate[_audio.audioStream['codec_name']](_audio.audioStream['bit_rate'])
296 if (_bitrate === -1) {
297 return localFfmpeg.audioCodec('copy')
298 }
299 }
300
301 // we favor VBR, if a good AAC encoder is available 291 // we favor VBR, if a good AAC encoder is available
302 if ((await checkFFmpegEncoders()).get('libfdk_aac')) { 292 if ((await checkFFmpegEncoders()).get('libfdk_aac')) {
303 return localFfmpeg 293 return localFfmpeg
@@ -305,5 +295,17 @@ async function standard (_ffmpeg) {
305 .audioQuality(5) 295 .audioQuality(5)
306 } 296 }
307 297
308 return localFfmpeg.audioBitrate(_bitrate) 298 // we try to reduce the ceiling bitrate by making rough correspondances of bitrates
299 // of course this is far from perfect, but it might save some space in the end
300 const audioCodecName = _audio.audioStream['codec_name']
301 let bitrate: number
302 if (audio.bitrate[audioCodecName]) {
303 bitrate = audio.bitrate[audioCodecName](_audio.audioStream['bit_rate'])
304
305 if (bitrate === -1) return localFfmpeg.audioCodec('copy')
306 }
307
308 if (bitrate !== undefined) return localFfmpeg.audioBitrate(bitrate)
309
310 return localFfmpeg
309} 311}