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.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 63dc5b6a3..7022d3e03 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -263,8 +263,9 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
263 return true 263 return true
264} 264}
265 265
266function getClosestFramerateStandard (fps: number, hd = false): number { 266function getClosestFramerateStandard (fps: number, type: 'HD_STANDARD' | 'STANDARD'): number {
267 return VIDEO_TRANSCODING_FPS[hd ? 'HD_STANDARD' : 'STANDARD'].slice(0).sort((a, b) => fps % a - fps % b)[0] 267 return VIDEO_TRANSCODING_FPS[type].slice(0)
268 .sort((a, b) => fps % a - fps % b)[0]
268} 269}
269 270
270// --------------------------------------------------------------------------- 271// ---------------------------------------------------------------------------
@@ -294,12 +295,10 @@ async function buildx264Command (command: ffmpeg.FfmpegCommand, options: Transco
294 // On small/medium resolutions, limit FPS 295 // On small/medium resolutions, limit FPS
295 options.resolution !== undefined && 296 options.resolution !== undefined &&
296 options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && 297 options.resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN &&
297 fps > VIDEO_TRANSCODING_FPS.AVERAGE || 298 fps > VIDEO_TRANSCODING_FPS.AVERAGE
298 // If the video is doesn't match hd standard
299 !VIDEO_TRANSCODING_FPS.HD_STANDARD.some(value => fps % value === 0)
300 ) { 299 ) {
301 // Get closest standard framerate by modulo: downsampling has to be done to a divisor of the nominal fps value 300 // Get closest standard framerate by modulo: downsampling has to be done to a divisor of the nominal fps value
302 fps = getClosestFramerateStandard(fps) 301 fps = getClosestFramerateStandard(fps, 'STANDARD')
303 } 302 }
304 303
305 command = await presetH264(command, options.inputPath, options.resolution, fps) 304 command = await presetH264(command, options.inputPath, options.resolution, fps)
@@ -312,7 +311,7 @@ async function buildx264Command (command: ffmpeg.FfmpegCommand, options: Transco
312 311
313 if (fps) { 312 if (fps) {
314 // Hard FPS limits 313 // Hard FPS limits
315 if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, true) 314 if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, 'HD_STANDARD')
316 else if (fps < VIDEO_TRANSCODING_FPS.MIN) fps = VIDEO_TRANSCODING_FPS.MIN 315 else if (fps < VIDEO_TRANSCODING_FPS.MIN) fps = VIDEO_TRANSCODING_FPS.MIN
317 316
318 command = command.withFPS(fps) 317 command = command.withFPS(fps)