1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Fix live FPS limit

This commit is contained in:
Chocobozzz 2020-11-26 11:29:50 +01:00
parent 0151c41c65
commit 884d2c39ae
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 68 additions and 42 deletions

View file

@ -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,