Documentation 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.
Overview
The encoding module provides types and functions for configuring and checking media encoding capabilities.Types
VideoEncodingConfig
Configuration object that controls video encoding.The video codec that should be used for encoding the video samples (frames).
The target bitrate for the encoded video, in bits per second. Alternatively, a subjective
Quality can be provided.The interval, in seconds, of how often frames are encoded as a key frame. Frequent key frames improve seeking behavior but increase file size. When using multiple video tracks, you should give them all the same key frame interval.
Video frames may change size over time. This field controls the behavior in case this happens.
'deny'(default): Throw an error, requiring all frames to have the exact same dimensions'passThrough': Allow the change and directly pass the frame to the encoder'fill': Stretch the image to fill the entire original box, potentially altering aspect ratio'contain': Contain the entire image within the original box while preserving aspect ratio (may cause letterboxing)'cover': Scale the image until the entire original box is filled, while preserving aspect ratio
What to do with alpha data contained in the video samples.
'discard'(default): Only the samples’ color data is kept; the video is opaque'keep': The samples’ alpha data is also encoded as side data. Pair this with a container format that supports transparency (WebM or Matroska)
Configures the bitrate mode.
The latency mode used by the encoder; controls the performance-quality tradeoff.
'quality'(default): The encoder prioritizes quality over latency, and no frames can be dropped'realtime': The encoder prioritizes low latency over quality, and may drop frames if overloaded
Called for each successfully encoded packet. Both the packet and the encoding metadata are passed.
Called when the internal encoder config is created.
AudioEncodingConfig
Configuration object that controls audio encoding.The audio codec that should be used for encoding the audio samples.
The target bitrate for the encoded audio, in bits per second. Alternatively, a subjective
Quality can be provided. Required for compressed audio codecs, unused for PCM codecs.Configures the bitrate mode.
Called for each successfully encoded packet. Both the packet and the encoding metadata are passed.
Called when the internal encoder config is created.
Quality
Represents a subjective media quality level.Quality constants
QUALITY_VERY_LOW
Represents a very low media quality.QUALITY_LOW
Represents a low media quality.QUALITY_MEDIUM
Represents a medium media quality.QUALITY_HIGH
Represents a high media quality.QUALITY_VERY_HIGH
Represents a very high media quality.Functions
canEncode
Checks if the browser is able to encode the given codec.The media codec to check for encoding support.
A promise that resolves to
true if the codec can be encoded, false otherwise.canEncodeVideo
Checks if the browser is able to encode the given video codec with the given parameters.The video codec to check.
Optional encoding parameters to test.
A promise that resolves to
true if the video codec can be encoded with the given parameters.canEncodeAudio
Checks if the browser is able to encode the given audio codec with the given parameters.The audio codec to check.
Optional encoding parameters to test.
A promise that resolves to
true if the audio codec can be encoded with the given parameters.canEncodeSubtitles
Checks if the browser is able to encode the given subtitle codec.The subtitle codec to check.
A promise that resolves to
true if the subtitle codec can be encoded.getEncodableCodecs
Returns the list of all media codecs that can be encoded by the browser.Array of all encodable video, audio, and subtitle codecs.
getEncodableVideoCodecs
Returns the list of all video codecs that can be encoded by the browser.Array of codecs to check. Defaults to all video codecs.
Optional parameters for encoding capability testing.
Array of encodable video codecs from the checked list.
getEncodableAudioCodecs
Returns the list of all audio codecs that can be encoded by the browser.Array of codecs to check. Defaults to all audio codecs.
Optional parameters for encoding capability testing.
Array of encodable audio codecs from the checked list.
getEncodableSubtitleCodecs
Returns the list of all subtitle codecs that can be encoded by the browser.Array of codecs to check. Defaults to all subtitle codecs.
Array of encodable subtitle codecs from the checked list.
getFirstEncodableVideoCodec
Returns the first video codec from the given list that can be encoded by the browser.The first encodable codec from the list, or
null if none are encodable.getFirstEncodableAudioCodec
Returns the first audio codec from the given list that can be encoded by the browser.The first encodable codec from the list, or
null if none are encodable.getFirstEncodableSubtitleCodec
Returns the first subtitle codec from the given list that can be encoded by the browser.Array of subtitle codecs to check.
The first encodable codec from the list, or
null if none are encodable.