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.
VideoSample
Represents a raw, unencoded video frame. Provides methods for creating, manipulating, and converting video frames across different formats.Constructor
Initialization options for the video sample.
Creating VideoSamples
From VideoFrame
VideoSample from a VideoFrame.
From Canvas
VideoSample by rendering a canvas element.
From Raw Pixels
VideoSample from raw pixel data.
Properties
The internal pixel format in which the frame is stored. One of 21 supported formats including I420, NV12, RGBA, etc.
The width of the frame in pixels.
The height of the frame in pixels.
The display width accounting for rotation and pixel aspect ratio.
The display height accounting for rotation and pixel aspect ratio.
The rotation of the frame in degrees (0, 90, 180, 270), clockwise.
The presentation timestamp in seconds.
The duration in seconds.
The color space information for the frame.
Methods
toVideoFrame()
Converts this sample to aVideoFrame.
copyToCanvas()
Draws this video sample onto a canvas.copyPixelsTo()
Copies the raw pixel data of this sample to a destination buffer.clone()
Creates a copy of this video sample.close()
Releases underlying resources. You must call this when you’re done using the sample.AudioSample
Represents a raw, unencoded audio buffer. Provides methods for creating, manipulating, and converting audio data.Constructor
Initialization options for the audio sample.
Creating AudioSamples
From AudioData
AudioSample from an AudioData.
From AudioBuffer
AudioSample from an AudioBuffer.
From Raw Audio Data
AudioSample from raw audio data.
Properties
The internal format of the audio data (e.g., ‘s16’, ‘f32’, ‘s32’, ‘f32-planar’).
The number of audio channels (e.g., 2 for stereo).
The number of audio frames in this sample.
The sample rate in Hz (e.g., 48000).
The presentation timestamp in seconds.
The duration in seconds.
Methods
toAudioData()
Converts this sample to anAudioData.
toAudioBuffer()
Converts this sample to anAudioBuffer.
copyDataTo()
Copies the raw audio data to a destination buffer.clone()
Creates a copy of this audio sample.close()
Releases underlying resources. You must call this when you’re done using the sample.VideoSamplePixelFormat
The internal pixel format with which a VideoSample is stored. See WebCodecs pixel formats for more details.VideoSampleColorSpace
Color space information for video samples.Example
See also
- Packets - Encoded compressed media data
- Packets and samples concept - Understanding the difference
- VideoSampleSource - Add video samples to output
- AudioSampleSource - Add audio samples to output
- VideoSampleSink - Extract video samples from input
- AudioSampleSink - Extract audio samples from input