29 lines
415 B
JavaScript
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)}`);
|
|
}
|