hls-test/sizes.js
2023-02-13 14:05:37 -08:00

29 lines
415 B
JavaScript

let heights = [
120,
180,
240,
360,
480,
720,
1080,
1440,
2160
];
let base = 480;
let bitrate = 1000;
let exponent = 0.85;
function area(h) {
let w = Math.round(h * 16 / 9);
return w * h;
}
function rate(h) {
let ratio = area(h) / area(base);
return Math.round(bitrate * (ratio ** exponent));
}
for (let h of heights) {
console.log(`${h}: ${rate(h)}`);
}