diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 26 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 8 |
2 files changed, 18 insertions, 16 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 | */ |
276 | async function standard (_ffmpeg) { | 276 | async 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 | } |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 58381a0e5..cab096a12 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -209,19 +209,19 @@ describe('Test multiple servers', function () { | |||
209 | files: [ | 209 | files: [ |
210 | { | 210 | { |
211 | resolution: 240, | 211 | resolution: 240, |
212 | size: 342000 | 212 | size: 187000 |
213 | }, | 213 | }, |
214 | { | 214 | { |
215 | resolution: 360, | 215 | resolution: 360, |
216 | size: 433000 | 216 | size: 278000 |
217 | }, | 217 | }, |
218 | { | 218 | { |
219 | resolution: 480, | 219 | resolution: 480, |
220 | size: 538000 | 220 | size: 383000 |
221 | }, | 221 | }, |
222 | { | 222 | { |
223 | resolution: 720, | 223 | resolution: 720, |
224 | size: 861000 | 224 | size: 706000 |
225 | } | 225 | } |
226 | ], | 226 | ], |
227 | thumbnailfile: 'thumbnail', | 227 | thumbnailfile: 'thumbnail', |