diff options
Diffstat (limited to 'server/helpers/ffprobe-utils.ts')
-rw-r--r-- | server/helpers/ffprobe-utils.ts | 21 |
1 files changed, 21 insertions, 0 deletions
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 | |||
247 | .sort((a, b) => fps % a - fps % b)[0] | 247 | .sort((a, b) => fps % a - fps % b)[0] |
248 | } | 248 | } |
249 | 249 | ||
250 | function computeFPS (fpsArg: number, resolution: VideoResolution) { | ||
251 | let fps = fpsArg | ||
252 | |||
253 | if ( | ||
254 | // On small/medium resolutions, limit FPS | ||
255 | resolution !== undefined && | ||
256 | resolution < VIDEO_TRANSCODING_FPS.KEEP_ORIGIN_FPS_RESOLUTION_MIN && | ||
257 | fps > VIDEO_TRANSCODING_FPS.AVERAGE | ||
258 | ) { | ||
259 | // Get closest standard framerate by modulo: downsampling has to be done to a divisor of the nominal fps value | ||
260 | fps = getClosestFramerateStandard(fps, 'STANDARD') | ||
261 | } | ||
262 | |||
263 | // Hard FPS limits | ||
264 | if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, 'HD_STANDARD') | ||
265 | else if (fps < VIDEO_TRANSCODING_FPS.MIN) fps = VIDEO_TRANSCODING_FPS.MIN | ||
266 | |||
267 | return fps | ||
268 | } | ||
269 | |||
250 | // --------------------------------------------------------------------------- | 270 | // --------------------------------------------------------------------------- |
251 | 271 | ||
252 | export { | 272 | export { |
@@ -259,6 +279,7 @@ export { | |||
259 | getVideoStreamFromFile, | 279 | getVideoStreamFromFile, |
260 | getDurationFromVideoFile, | 280 | getDurationFromVideoFile, |
261 | getAudioStream, | 281 | getAudioStream, |
282 | computeFPS, | ||
262 | getVideoFileFPS, | 283 | getVideoFileFPS, |
263 | ffprobePromise, | 284 | ffprobePromise, |
264 | getClosestFramerateStandard, | 285 | getClosestFramerateStandard, |