+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')
+
+ if (fps < VIDEO_TRANSCODING_FPS.MIN) {
+ throw new Error(`Cannot compute FPS because ${fps} is lower than our minimum value ${VIDEO_TRANSCODING_FPS.MIN}`)
+ }
+
+ return fps
+}
+