hls-test/sizes.js

30 lines
415 B
JavaScript
Raw Normal View History

2023-02-13 22:05:37 +00:00
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)}`);
}