]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/models/videos/video-resolution.enum.ts
Add ability for plugins to specify scale filter
[github/Chocobozzz/PeerTube.git] / shared / models / videos / video-resolution.enum.ts
index 8b5a96cb6725fd09e241f4517be35ff73c06ac7a..a5d2ac7fae3d56e02a31b8815b8197e95f8294b6 100644 (file)
@@ -1,12 +1,13 @@
 import { VideoTranscodingFPS } from './video-transcoding-fps.model'
 
-export enum VideoResolution {
+export const enum VideoResolution {
   H_NOVIDEO = 0,
   H_240P = 240,
   H_360P = 360,
   H_480P = 480,
   H_720P = 720,
   H_1080P = 1080,
+  H_1440P = 1440,
   H_4K = 2160
 }
 
@@ -53,9 +54,15 @@ function getBaseBitrate (resolution: number) {
     return 5200 * 1000
   }
 
+  if (resolution <= VideoResolution.H_1440P) {
+    // quality according to Google Live Encoder: 6000 - 13000 Kbps
+    // Quality according to YouTube Video Info: 8600 (av01) - 17000 (vp9.2) Kbps
+    return 10_000 * 1000
+  }
+
   // 4K
   // quality according to Google Live Encoder: 13000 - 34000 Kbps
-  return 22000 * 1000
+  return 22_000 * 1000
 }
 
 /**
@@ -81,7 +88,7 @@ export function getTargetBitrate (resolution: number, fps: number, fpsTranscodin
   // Example outputs:
   // 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps
   //  720p10: 1283 kbps,  720p30: 1750 kbps,  720p60: 2450 kbps
-  return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference)
+  return Math.floor(baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference))
 }
 
 /**