From 884d2c39ae23b44d0d037aaff0f66ad9ae0807ba Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Nov 2020 11:29:50 +0100 Subject: Fix live FPS limit --- server/helpers/ffprobe-utils.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server/helpers/ffprobe-utils.ts') diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 16b295bbd..1cf397767 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts @@ -247,6 +247,26 @@ function getClosestFramerateStandard (fps: number, type: 'HD_STANDARD' | 'STANDA .sort((a, b) => fps % a - fps % b)[0] } +function computeFPS (fpsArg: number, resolution: VideoResolution) { + let fps = fpsArg + + if ( + // On small/medium resolutions, limit FPS + resolution !== undefined && + resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && + fps > VIDEO_TRANSCODING_FPS.AVERAGE + ) { + // Get closest standard framerate by modulo: downsampling has to be done to a divisor of the nominal fps value + fps = getClosestFramerateStandard(fps, 'STANDARD') + } + + // Hard FPS limits + if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, 'HD_STANDARD') + else if (fps < VIDEO_TRANSCODING_FPS.MIN) fps = VIDEO_TRANSCODING_FPS.MIN + + return fps +} + // --------------------------------------------------------------------------- export { @@ -259,6 +279,7 @@ export { getVideoStreamFromFile, getDurationFromVideoFile, getAudioStream, + computeFPS, getVideoFileFPS, ffprobePromise, getClosestFramerateStandard, -- cgit v1.2.3