mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 03:13:51 +02:00
Conversion.init(hardwareAcceleration) option (#254)
* Support Conversion.init(hardwareAcceleration) option passed down to the VideoEncodingConfig. fix #253 * Few changes --------- Co-authored-by: Raphaël Droz <[email protected]> Co-authored-by: Vanilagy <[email protected]>
This commit is contained in:
co-authored by
Raphaël Droz
Vanilagy
parent
228721d68f
commit
4dd747a0a6
@@ -186,6 +186,11 @@ export type ConversionVideoOptions = {
|
||||
* Setting this fields forces a transcode.
|
||||
*/
|
||||
keyFrameInterval?: number;
|
||||
/**
|
||||
* A hint that configures the hardware acceleration method used when transcoding. This is best left on
|
||||
* `'no-preference'`, the default.
|
||||
*/
|
||||
hardwareAcceleration?: 'no-preference' | 'prefer-hardware' | 'prefer-software';
|
||||
/** When `true`, video will always be re-encoded instead of directly copying over the encoded samples. */
|
||||
forceTranscode?: boolean;
|
||||
/**
|
||||
@@ -346,6 +351,15 @@ const validateVideoOptions = (videoOptions: ConversionVideoOptions | undefined)
|
||||
) {
|
||||
throw new TypeError('options.video.processedHeight, when provided, must be a positive integer.');
|
||||
}
|
||||
if (
|
||||
videoOptions?.hardwareAcceleration !== undefined
|
||||
&& !['no-preference', 'prefer-hardware', 'prefer-software'].includes(videoOptions.hardwareAcceleration)
|
||||
) {
|
||||
throw new TypeError(
|
||||
'options.video.hardwareAcceleration, when provided, must be \'no-preference\', \'prefer-hardware\' or'
|
||||
+ ' \'prefer-software\'.',
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const validateAudioOptions = (audioOptions: ConversionAudioOptions | undefined) => {
|
||||
@@ -984,6 +998,7 @@ export class Conversion {
|
||||
keyFrameInterval: trackOptions.keyFrameInterval,
|
||||
sizeChangeBehavior: trackOptions.fit ?? 'passThrough',
|
||||
alpha,
|
||||
hardwareAcceleration: trackOptions.hardwareAcceleration,
|
||||
};
|
||||
|
||||
const source = new VideoSampleSource(encodingConfig);
|
||||
|
||||
Reference in New Issue
Block a user