TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Vanilagy/mediabunny/llms.txt
Use this file to discover all available pages before exploring further.
Conversion class provides a high-level API for converting one media file into another. It supports transcoding, resizing, rotating, trimming, and processing video and audio tracks.
Static methods
Conversion.init()
Configuration for the conversion
Properties
The input file.
The output file.
Whether this conversion, as it has been configured, is valid and can be executed. If this field is false, check the
discardedTracks field for reasons.The list of tracks that are included in the output file.
The list of tracks from the input file that have been discarded, alongside the discard reason.
A callback that is fired whenever the conversion progresses. Returns a number between 0 and 1, indicating the completion of the conversion. Must be set before
execute() is called for progress to be computed.Methods
execute()
isValid is false.
cancel()
execute call to throw a ConversionCanceledError. Does nothing if the conversion is already complete.
Video options
ConversionVideoOptions
If
true, all video tracks will be discarded and will not be present in the output.The desired width of the output video in pixels, defaulting to the video’s natural display width. If height is not set, it will be deduced automatically based on aspect ratio.
The desired height of the output video in pixels, defaulting to the video’s natural display height. If width is not set, it will be deduced automatically based on aspect ratio.
The fitting algorithm in case both width and height are set:
'fill'will stretch the image to fill the entire box, potentially altering aspect ratio.'contain'will contain the entire image within the box while preserving aspect ratio. This may lead to letterboxing.'cover'will scale the image until the entire box is filled, while preserving aspect ratio.
The angle in degrees to rotate the input video by, clockwise. Must be 0, 90, 180, or 270. Rotation is applied before cropping and resizing. This rotation is in addition to the natural rotation of the input video.
When enabled, Mediabunny will use the rotation metadata in the output file to perform video rotation whenever possible. Set this field to
false if you want to ensure the output file does not make use of rotation metadata.Specifies the rectangular region of the input video to crop to
The desired frame rate of the output video, in hertz. If not specified, the original input frame rate will be used (which may be variable).
The desired output video codec.
The desired bitrate of the output video.
Whether to discard or keep the transparency information of the input video. Note that for
'keep' to produce a transparent video, you must use an output config that supports it, such as WebM with VP9.The interval, in seconds, of how often frames are encoded as a key frame. Frequent key frames improve seeking behavior but increase file size.
hardwareAcceleration
'no-preference' | 'prefer-hardware' | 'prefer-software'
default:"'no-preference'"
A hint that configures the hardware acceleration method used when transcoding.
When
true, video will always be re-encoded instead of directly copying over the encoded samples.Allows for custom user-defined processing of video frames, e.g. for applying overlays, color transformations, or timestamp modifications. Will be called for each input video sample after transformations and frame rate corrections.
An optional hint specifying the width of video samples returned by the
process function, for better encoder configuration.An optional hint specifying the height of video samples returned by the
process function, for better encoder configuration.Audio options
ConversionAudioOptions
If
true, all audio tracks will be discarded and will not be present in the output.The desired channel count of the output audio.
The desired sample rate of the output audio, in hertz.
The desired output audio codec.
The desired bitrate of the output audio.
When
true, audio will always be re-encoded instead of directly copying over the encoded samples.Allows for custom user-defined processing of audio samples, e.g. for applying audio effects, transformations, or timestamp modifications. Will be called for each input audio sample after remixing and resampling.
An optional hint specifying the channel count of audio samples returned by the
process function, for better encoder configuration.An optional hint specifying the sample rate of audio samples returned by the
process function, for better encoder configuration.