aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffprobe-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-26 11:29:50 +0100
committerChocobozzz <me@florianbigard.com>2020-11-26 11:30:18 +0100
commit884d2c39ae23b44d0d037aaff0f66ad9ae0807ba (patch)
tree1e06fa6954a987b08894c574e31db7e8c106bafe /server/helpers/ffprobe-utils.ts
parent0151c41c65e0e3e94288314afe295358b9d698f7 (diff)
downloadPeerTube-884d2c39ae23b44d0d037aaff0f66ad9ae0807ba.tar.gz
PeerTube-884d2c39ae23b44d0d037aaff0f66ad9ae0807ba.tar.zst
PeerTube-884d2c39ae23b44d0d037aaff0f66ad9ae0807ba.zip
Fix live FPS limit
Diffstat (limited to 'server/helpers/ffprobe-utils.ts')
-rw-r--r--server/helpers/ffprobe-utils.ts21
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
250function 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
252export { 272export {
@@ -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,