@codenoobforreal/clitools
Version:
CLI tool for video processing (H.265/HEVC encoding & QuickTime compatibility) using FFmpeg, and batch lossless image compression with format preservation
17 lines • 574 B
JavaScript
/**
* calculate crf value base on video resolution
*
* https://handbrake.fr/docs/en/1.9.0/workflow/adjust-quality.html
* @param pixelCount resolution pixels
* @returns constant frame rate
*/
export function calculateCrfByPixelCount(pixelCount) {
const CRF_THRESHOLDS = [
{ pixelCount: 8_294_400, crf: 22 },
{ pixelCount: 2_073_600, crf: 20 },
{ pixelCount: 921_600, crf: 19 },
];
const threshold = CRF_THRESHOLDS.find((t) => pixelCount >= t.pixelCount);
return threshold?.crf ?? 18;
}
//# sourceMappingURL=crf-calculation.js.map