aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/videos/bitrate.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/shared/core-utils/videos/bitrate.ts b/shared/core-utils/videos/bitrate.ts
index 18c6e2f6c..c1891188f 100644
--- a/shared/core-utils/videos/bitrate.ts
+++ b/shared/core-utils/videos/bitrate.ts
@@ -4,6 +4,18 @@ type BitPerPixel = { [ id in VideoResolution ]: number }
4 4
5// https://bitmovin.com/video-bitrate-streaming-hls-dash/ 5// https://bitmovin.com/video-bitrate-streaming-hls-dash/
6 6
7const minLimitBitPerPixel: BitPerPixel = {
8 [VideoResolution.H_NOVIDEO]: 0,
9 [VideoResolution.H_144P]: 0.02,
10 [VideoResolution.H_240P]: 0.02,
11 [VideoResolution.H_360P]: 0.02,
12 [VideoResolution.H_480P]: 0.02,
13 [VideoResolution.H_720P]: 0.02,
14 [VideoResolution.H_1080P]: 0.02,
15 [VideoResolution.H_1440P]: 0.02,
16 [VideoResolution.H_4K]: 0.02
17}
18
7const averageBitPerPixel: BitPerPixel = { 19const averageBitPerPixel: BitPerPixel = {
8 [VideoResolution.H_NOVIDEO]: 0, 20 [VideoResolution.H_NOVIDEO]: 0,
9 [VideoResolution.H_144P]: 0.19, 21 [VideoResolution.H_144P]: 0.19,
@@ -50,11 +62,23 @@ function getMaxBitrate (options: {
50 return targetBitrate 62 return targetBitrate
51} 63}
52 64
65function getMinLimitBitrate (options: {
66 resolution: VideoResolution
67 ratio: number
68 fps: number
69}) {
70 const minLimitBitrate = calculateBitrate({ ...options, bitPerPixel: minLimitBitPerPixel })
71 if (!minLimitBitrate) return 10 * 1000
72
73 return minLimitBitrate
74}
75
53// --------------------------------------------------------------------------- 76// ---------------------------------------------------------------------------
54 77
55export { 78export {
56 getAverageBitrate, 79 getAverageBitrate,
57 getMaxBitrate 80 getMaxBitrate,
81 getMinLimitBitrate
58} 82}
59 83
60// --------------------------------------------------------------------------- 84// ---------------------------------------------------------------------------