Frame

expect class Frame : AutoCloseable

One decoded frame (video or audio), backed by an opaque native owner. Close it to release the buffers.

Ownership rule. Frames emitted by the public Flow APIs (MediaSource.decodedFrames, MediaSource.decodeStreams, FilterGraph.process) are owned by the collector. Each frame stays valid until you close it. Close every collected frame. An unclosed frame leaks its native buffers. Frames handed to a callback (FilterGraph.feedInput's onOutput) are valid only for that call. Call copy to take an owned snapshot of one.

Buffering rule. toList() is safe: every frame reaches you. Do not put frames through a channel the standard library made: buffer(), flowOn, conflate and produceIn all queue elements they cannot close, so cancelling part way through (buffer().take(1) is the ordinary case) drops whatever is still queued and leaks it. Use bufferFrames instead, which owns its channel and closes what you never receive; it takes a context for the flowOn case too.

The native representation is intentionally not exposed. Pipeline operators (FilterGraph, encoders) accept Frames directly and resolve their platform handle internally.

actual class Frame : AutoCloseable

One decoded frame (video or audio), backed by an opaque native owner. Close it to release the buffers.

Ownership rule. Frames emitted by the public Flow APIs (MediaSource.decodedFrames, MediaSource.decodeStreams, FilterGraph.process) are owned by the collector. Each frame stays valid until you close it. Close every collected frame. An unclosed frame leaks its native buffers. Frames handed to a callback (FilterGraph.feedInput's onOutput) are valid only for that call. Call copy to take an owned snapshot of one.

Buffering rule. toList() is safe: every frame reaches you. Do not put frames through a channel the standard library made: buffer(), flowOn, conflate and produceIn all queue elements they cannot close, so cancelling part way through (buffer().take(1) is the ordinary case) drops whatever is still queued and leaks it. Use bufferFrames instead, which owns its channel and closes what you never receive; it takes a context for the flowOn case too.

The native representation is intentionally not exposed. Pipeline operators (FilterGraph, encoders) accept Frames directly and resolve their platform handle internally.

actual class Frame : AutoCloseable

One decoded or constructed picture or block of audio, held in native memory. Read it through info and copyPlanesToByteArray, and close it when done.

actual class Frame : AutoCloseable

One decoded frame (video or audio), backed by an opaque native owner. Close it to release the buffers.

Ownership rule. Frames emitted by the public Flow APIs (MediaSource.decodedFrames, MediaSource.decodeStreams, FilterGraph.process) are owned by the collector. Each frame stays valid until you close it. Close every collected frame. An unclosed frame leaks its native buffers. Frames handed to a callback (FilterGraph.feedInput's onOutput) are valid only for that call. Call copy to take an owned snapshot of one.

Buffering rule. toList() is safe: every frame reaches you. Do not put frames through a channel the standard library made: buffer(), flowOn, conflate and produceIn all queue elements they cannot close, so cancelling part way through (buffer().take(1) is the ordinary case) drops whatever is still queued and leaks it. Use bufferFrames instead, which owns its channel and closes what you never receive; it takes a context for the flowOn case too.

The native representation is intentionally not exposed. Pipeline operators (FilterGraph, encoders) accept Frames directly and resolve their platform handle internally.

actual class Frame : AutoCloseable

A decoded frame, as a handle into the codec module.

The pointer is an opaque Int on this side and is never dereferenced here; every read is a call. The frame is owned: close frees it, and closing twice is a no-op because the pointer is cleared.

Types

Link copied to clipboard
expect object Companion
actual object Companion
actual object Companion
actual object Companion
actual object Companion

Properties

Link copied to clipboard

FrameInfo.duration converted to microseconds. Null when the decoder supplied no duration. A duration is an interval, so no container start offset applies to it.

Link copied to clipboard

The hardware surface behind this frame, or null when its pixels are in main memory.

Link copied to clipboard
expect val info: FrameInfo
actual val info: FrameInfo
actual val info: FrameInfo
actual val info: FrameInfo
actual val info: FrameInfo
Link copied to clipboard

FrameInfo.pts converted to microseconds on the stream's own timeline. Null when the frame carries no timestamp.

Functions

Link copied to clipboard

Starts the Dolby Vision composition of this video frame, which turns its base layer and RPU into an HDR10 picture. See DolbyVisionComposition for what the picture is and how to spread the work over several threads.

Starts the Dolby Vision composition of this video frame, which turns its base layer and RPU into an HDR10 picture. See DolbyVisionComposition for what the picture is and how to spread the work over several threads.

Starts the Dolby Vision composition of this video frame, which turns its base layer and RPU into an HDR10 picture. See DolbyVisionComposition for what the picture is and how to spread the work over several threads.

Starts the Dolby Vision composition of this video frame, which turns its base layer and RPU into an HDR10 picture. See DolbyVisionComposition for what the picture is and how to spread the work over several threads.

Starts the Dolby Vision composition of this video frame, which turns its base layer and RPU into an HDR10 picture. See DolbyVisionComposition for what the picture is and how to spread the work over several threads.

Link copied to clipboard
expect open override fun close()
actual open override fun close()
actual open override fun close()
actual open override fun close()
actual open override fun close()
Link copied to clipboard
expect fun closedCaptions(): ByteArray?

The CEA-608 and CEA-708 closed captions this video frame carries: the cc_data of its ATSC A/53 part 4 side data, three bytes per caption pair. In each triplet the first byte holds the valid flag and the caption type, and the other two hold the caption data.

actual fun closedCaptions(): ByteArray?

The CEA-608 and CEA-708 closed captions this video frame carries: the cc_data of its ATSC A/53 part 4 side data, three bytes per caption pair. In each triplet the first byte holds the valid flag and the caption type, and the other two hold the caption data.

actual fun closedCaptions(): ByteArray?

The CEA-608 and CEA-708 closed captions this video frame carries: the cc_data of its ATSC A/53 part 4 side data, three bytes per caption pair. In each triplet the first byte holds the valid flag and the caption type, and the other two hold the caption data.

actual fun closedCaptions(): ByteArray?

The CEA-608 and CEA-708 closed captions this video frame carries: the cc_data of its ATSC A/53 part 4 side data, three bytes per caption pair. In each triplet the first byte holds the valid flag and the caption type, and the other two hold the caption data.

actual fun closedCaptions(): ByteArray?

The CEA-608 and CEA-708 closed captions this video frame carries: the cc_data of its ATSC A/53 part 4 side data, three bytes per caption pair. In each triplet the first byte holds the valid flag and the caption type, and the other two hold the caption data.

Link copied to clipboard
expect fun composeDolbyVision(): Frame?

The Dolby Vision composition of this video frame in one call, on the calling thread: beginDolbyVisionComposition, every row, and the picture. The frame itself is untouched.

actual fun composeDolbyVision(): Frame?

The Dolby Vision composition of this video frame in one call, on the calling thread: beginDolbyVisionComposition, every row, and the picture. The frame itself is untouched.

actual fun composeDolbyVision(): Frame?

The Dolby Vision composition of this video frame in one call, on the calling thread: beginDolbyVisionComposition, every row, and the picture. The frame itself is untouched.

actual fun composeDolbyVision(): Frame?

The Dolby Vision composition of this video frame in one call, on the calling thread: beginDolbyVisionComposition, every row, and the picture. The frame itself is untouched.

actual fun composeDolbyVision(): Frame?

The Dolby Vision composition of this video frame in one call, on the calling thread: beginDolbyVisionComposition, every row, and the picture. The frame itself is untouched.

Link copied to clipboard
expect fun copy(): Frame

An owned snapshot of this frame. Use it to keep a callback-scoped frame past that call. O(1): it takes new references to the same refcounted buffers, with no pixel copy. The returned frame survives the source being recycled. Close it yourself.

actual fun copy(): Frame

An owned snapshot of this frame. Use it to keep a callback-scoped frame past that call. O(1): it takes new references to the same refcounted buffers, with no pixel copy. The returned frame survives the source being recycled. Close it yourself.

actual fun copy(): Frame

An owned snapshot of this frame. Use it to keep a callback-scoped frame past that call. O(1): it takes new references to the same refcounted buffers, with no pixel copy. The returned frame survives the source being recycled. Close it yourself.

actual fun copy(): Frame

An owned snapshot of this frame. Use it to keep a callback-scoped frame past that call. O(1): it takes new references to the same refcounted buffers, with no pixel copy. The returned frame survives the source being recycled. Close it yourself.

actual fun copy(): Frame

An owned snapshot of this frame. Use it to keep a callback-scoped frame past that call. O(1): it takes new references to the same refcounted buffers, with no pixel copy. The returned frame survives the source being recycled. Close it yourself.

Link copied to clipboard
expect fun copyPlanesInto(destination: ByteArray): Int

Copies the same bytes as copyPlanesToByteArray into destination, from index 0, and leaves the rest of destination as it was. A converter that keeps one array for every frame of a stream allocates nothing per frame. Size the array with planesByteCount.

actual fun copyPlanesInto(destination: ByteArray): Int

Copies the same bytes as copyPlanesToByteArray into destination, from index 0, and leaves the rest of destination as it was. A converter that keeps one array for every frame of a stream allocates nothing per frame. Size the array with planesByteCount.

actual fun copyPlanesInto(destination: ByteArray): Int

Copies the same bytes as copyPlanesToByteArray into destination, from index 0, and leaves the rest of destination as it was. A converter that keeps one array for every frame of a stream allocates nothing per frame. Size the array with planesByteCount.

actual fun copyPlanesInto(destination: ByteArray): Int

Copies the same bytes as copyPlanesToByteArray into destination, from index 0, and leaves the rest of destination as it was. A converter that keeps one array for every frame of a stream allocates nothing per frame. Size the array with planesByteCount.

actual fun copyPlanesInto(destination: ByteArray): Int

Copies the same bytes as copyPlanesToByteArray into destination, from index 0, and leaves the rest of destination as it was. A converter that keeps one array for every frame of a stream allocates nothing per frame. Size the array with planesByteCount.

Link copied to clipboard

Copy the frame's pixel planes (video) or samples (audio) into a flat ByteArray. Planar formats stay planar and packed formats stay packed, with no linesize padding (align=1, tightly packed). For yuv420p at WxH this returns W*H*3/2 bytes (Y plane, then U, then V); for fltp stereo it returns the left plane followed by the right. Frame.ofVideo / Frame.ofAudio accept exactly this layout back.

Copy the frame's pixel planes (video) or samples (audio) into a flat ByteArray. Planar formats stay planar and packed formats stay packed, with no linesize padding (align=1, tightly packed). For yuv420p at WxH this returns W*H*3/2 bytes (Y plane, then U, then V); for fltp stereo it returns the left plane followed by the right. Frame.ofVideo / Frame.ofAudio accept exactly this layout back.

Copy the frame's pixel planes (video) or samples (audio) into a flat ByteArray. Planar formats stay planar and packed formats stay packed, with no linesize padding (align=1, tightly packed). For yuv420p at WxH this returns W*H*3/2 bytes (Y plane, then U, then V); for fltp stereo it returns the left plane followed by the right. Frame.ofVideo / Frame.ofAudio accept exactly this layout back.

Copy the frame's pixel planes (video) or samples (audio) into a flat ByteArray. Planar formats stay planar and packed formats stay packed, with no linesize padding (align=1, tightly packed). For yuv420p at WxH this returns W*H*3/2 bytes (Y plane, then U, then V); for fltp stereo it returns the left plane followed by the right. Frame.ofVideo / Frame.ofAudio accept exactly this layout back.

Copy the frame's pixel planes (video) or samples (audio) into a flat ByteArray. Planar formats stay planar and packed formats stay packed, with no linesize padding (align=1, tightly packed). For yuv420p at WxH this returns W*H*3/2 bytes (Y plane, then U, then V); for fltp stereo it returns the left plane followed by the right. Frame.ofVideo / Frame.ofAudio accept exactly this layout back.

Link copied to clipboard

The Dolby Vision metadata of this video frame, from the RPU that FFmpeg's HEVC or AV1 decoder parsed and attached to it. A decoder attaches it on its own, with no option, to every frame of a stream that carries an RPU, whether the decoder runs in software or hands the picture to hardware.

The Dolby Vision metadata of this video frame, from the RPU that FFmpeg's HEVC or AV1 decoder parsed and attached to it. A decoder attaches it on its own, with no option, to every frame of a stream that carries an RPU, whether the decoder runs in software or hands the picture to hardware.

The Dolby Vision metadata of this video frame, from the RPU that FFmpeg's HEVC or AV1 decoder parsed and attached to it. A decoder attaches it on its own, with no option, to every frame of a stream that carries an RPU, whether the decoder runs in software or hands the picture to hardware.

The Dolby Vision metadata of this video frame, from the RPU that FFmpeg's HEVC or AV1 decoder parsed and attached to it. A decoder attaches it on its own, with no option, to every frame of a stream that carries an RPU, whether the decoder runs in software or hands the picture to hardware.

The Dolby Vision metadata of this video frame, from the RPU that FFmpeg's HEVC or AV1 decoder parsed and attached to it. A decoder attaches it on its own, with no option, to every frame of a stream that carries an RPU, whether the decoder runs in software or hands the picture to hardware.

Link copied to clipboard

The whole Dolby Vision RPU of this video frame as FFmpeg's decoder parsed it: the reshaping curves, the inverse quantization and the colour matrices, which dolbyVision leaves out. See DolbyVisionRpu.

The whole Dolby Vision RPU of this video frame as FFmpeg's decoder parsed it: the reshaping curves, the inverse quantization and the colour matrices, which dolbyVision leaves out. See DolbyVisionRpu.

The whole Dolby Vision RPU of this video frame as FFmpeg's decoder parsed it: the reshaping curves, the inverse quantization and the colour matrices, which dolbyVision leaves out. See DolbyVisionRpu.

The whole Dolby Vision RPU of this video frame as FFmpeg's decoder parsed it: the reshaping curves, the inverse quantization and the colour matrices, which dolbyVision leaves out. See DolbyVisionRpu.

The whole Dolby Vision RPU of this video frame as FFmpeg's decoder parsed it: the reshaping curves, the inverse quantization and the colour matrices, which dolbyVision leaves out. See DolbyVisionRpu.

Link copied to clipboard

The software download of a hardware frame: copies the pixels out of GPU memory into a new ordinary frame and carries the presentation properties (pts, colour, rotation side data) with them. It is the fallback made explicit: a renderer that cannot take the hardware surface calls this once per frame and pays the copy knowingly, and can report that it did.

The software download of a hardware frame: copies the pixels out of GPU memory into a new ordinary frame and carries the presentation properties (pts, colour, rotation side data) with them. It is the fallback made explicit: a renderer that cannot take the hardware surface calls this once per frame and pays the copy knowingly, and can report that it did.

The software download of a hardware frame: copies the pixels out of GPU memory into a new ordinary frame and carries the presentation properties (pts, colour, rotation side data) with them. It is the fallback made explicit: a renderer that cannot take the hardware surface calls this once per frame and pays the copy knowingly, and can report that it did.

The software download of a hardware frame: copies the pixels out of GPU memory into a new ordinary frame and carries the presentation properties (pts, colour, rotation side data) with them. It is the fallback made explicit: a renderer that cannot take the hardware surface calls this once per frame and pays the copy knowingly, and can report that it did.

Refused, because no hardware frame exists on this backend: the wasm decoder is software by construction, so every frame here is already the software one this would produce.

Link copied to clipboard
expect fun encodeImage(codec: CodecId = CodecId.Mjpeg): ByteArray

Encode this (video) frame as a standalone compressed image: MJPEG (.jpg) by default, or CodecId.Png. This converts the pixel format automatically when the image codec does not accept the frame's own (e.g. yuv420p → rgb24 for PNG). It leaves this frame untouched, timestamp included, so a frame can be thumbnailed and still encoded into a video.

actual fun encodeImage(codec: CodecId): ByteArray

Encode this (video) frame as a standalone compressed image: MJPEG (.jpg) by default, or CodecId.Png. This converts the pixel format automatically when the image codec does not accept the frame's own (e.g. yuv420p → rgb24 for PNG). It leaves this frame untouched, timestamp included, so a frame can be thumbnailed and still encoded into a video.

actual fun encodeImage(codec: CodecId): ByteArray

Encode this (video) frame as a standalone compressed image: MJPEG (.jpg) by default, or CodecId.Png. This converts the pixel format automatically when the image codec does not accept the frame's own (e.g. yuv420p → rgb24 for PNG). It leaves this frame untouched, timestamp included, so a frame can be thumbnailed and still encoded into a video.

actual fun encodeImage(codec: CodecId): ByteArray

Encode this (video) frame as a standalone compressed image: MJPEG (.jpg) by default, or CodecId.Png. This converts the pixel format automatically when the image codec does not accept the frame's own (e.g. yuv420p → rgb24 for PNG). It leaves this frame untouched, timestamp included, so a frame can be thumbnailed and still encoded into a video.

actual fun encodeImage(codec: CodecId): ByteArray

Encode this (video) frame as a standalone compressed image: MJPEG (.jpg) by default, or CodecId.Png. This converts the pixel format automatically when the image codec does not accept the frame's own (e.g. yuv420p → rgb24 for PNG). It leaves this frame untouched, timestamp included, so a frame can be thumbnailed and still encoded into a video.

Link copied to clipboard
expect fun planesByteCount(): Int

The number of bytes copyPlanesToByteArray returns for this frame, which is the size copyPlanesInto needs.

actual fun planesByteCount(): Int

The number of bytes copyPlanesToByteArray returns for this frame, which is the size copyPlanesInto needs.

actual fun planesByteCount(): Int

The number of bytes copyPlanesToByteArray returns for this frame, which is the size copyPlanesInto needs.

actual fun planesByteCount(): Int

The number of bytes copyPlanesToByteArray returns for this frame, which is the size copyPlanesInto needs.

actual fun planesByteCount(): Int

The number of bytes copyPlanesToByteArray returns for this frame, which is the size copyPlanesInto needs.

Link copied to clipboard
fun <R> Frame.withPlanes(block: (planes: List<CPointer<UByteVar>>, strides: List<Int>, heights: List<Int>) -> R): R

Reads a video frame's planes without copying them.