mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 11:23:45 +02:00
Implement @mediabunny/prores extension, add onError callbacks to custom coders, fix visibleRect bug in VideoSample
This commit is contained in:
+6
-6
@@ -549,20 +549,20 @@ export class Quality {
|
||||
/** @internal */
|
||||
_toVideoBitrate(codec: VideoCodec, width: number, height: number) {
|
||||
const pixels = width * height;
|
||||
const referencePixels = 1920 * 1080;
|
||||
const referenceBitrate = 3_000_000;
|
||||
const scaleFactor = Math.pow(pixels / referencePixels, 0.95); // Slight non-linear scaling
|
||||
const baseBitrate = referenceBitrate * scaleFactor;
|
||||
|
||||
const codecEfficiencyFactors = {
|
||||
const codecEfficiencyFactors: Record<VideoCodec, number> = {
|
||||
avc: 1.0, // H.264/AVC (baseline)
|
||||
hevc: 0.6, // H.265/HEVC (~40% more efficient than AVC)
|
||||
vp9: 0.6, // Similar to HEVC
|
||||
av1: 0.4, // ~60% more efficient than AVC
|
||||
vp8: 1.2, // Slightly less efficient than AVC
|
||||
prores: 220_000_000 / referenceBitrate, // Apple ProRes white paper claims 220 Mbps for 1080p 422 HQ @30Hz
|
||||
};
|
||||
|
||||
const referencePixels = 1920 * 1080;
|
||||
const referenceBitrate = 3000000;
|
||||
const scaleFactor = Math.pow(pixels / referencePixels, 0.95); // Slight non-linear scaling
|
||||
const baseBitrate = referenceBitrate * scaleFactor;
|
||||
|
||||
const codecAdjustedBitrate = baseBitrate * codecEfficiencyFactors[codec];
|
||||
const finalBitrate = codecAdjustedBitrate * this._factor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user