Package-level declarations

Types

Link copied to clipboard

One configured and opened audio encoder. Some codecs require a fixed input chunk size (AAC: 1024 samples). For those, route frames through FilterGraph.buildAudio and call FilterGraph.setOutputFrameSize with frameSize (Transcoder does this automatically).

One configured and opened audio encoder. Some codecs require a fixed input chunk size (AAC: 1024 samples). For those, route frames through FilterGraph.buildAudio and call FilterGraph.setOutputFrameSize with frameSize (Transcoder does this automatically).

One configured and opened audio encoder. Some codecs require a fixed input chunk size (AAC: 1024 samples). For those, route frames through FilterGraph.buildAudio and call FilterGraph.setOutputFrameSize with frameSize (Transcoder does this automatically).

One configured and opened audio encoder. Some codecs require a fixed input chunk size (AAC: 1024 samples). For those, route frames through FilterGraph.buildAudio and call FilterGraph.setOutputFrameSize with frameSize (Transcoder does this automatically).

Link copied to clipboard
data class AudioEncoderSpec(val codec: CodecId, val sampleRate: Int, val channels: Int = 2, val sampleFormat: SampleFormat = SampleFormat.None, val bitrateBps: Long, val options: Map<String, String> = emptyMap())
Link copied to clipboard
data class AudioInput(val sampleRate: Int, val sampleFormat: SampleFormat, val channels: Int, val timeBase: Rational)

Per-input description for FilterGraph.buildAudioMulti.

Link copied to clipboard
data class AudioStreamInfo(val sampleRate: Int, val channels: Int, val sampleFormat: SampleFormat, val channelLayoutMask: Long? = null)
Link copied to clipboard
data class Chapter(val id: Long, val startMicros: Long, val endMicros: Long, val metadata: Map<String, String> = emptyMap())

One container chapter (KD-5), bounds in microseconds on the same ABSOLUTE timeline every other timestamp KiteFFmpeg reports uses (subtract MediaSource.startTimeMicros to move onto the relative timeline seeks accept).

Link copied to clipboard

Where a chroma sample sits relative to its luma samples. Values match FFmpeg's AVChromaLocation.

Link copied to clipboard
value class CodecId(val name: String)

Codec identifier: symbolic name (h264, aac, libx264). Matches avcodec_find_*_by_name.

Link copied to clipboard
data class ColorInfo(val matrix: ColorMatrix = ColorMatrix.Unspecified, val primaries: ColorPrimaries = ColorPrimaries.Unspecified, val transfer: ColorTransfer = ColorTransfer.Unspecified, val fullRange: Boolean = false, val chromaLocation: ChromaLocation = ChromaLocation.Unspecified, val rangeSpecified: Boolean = false, val matrixSpecified: Boolean = false, val primariesSpecified: Boolean = false, val transferSpecified: Boolean = false)

The colour metadata a renderer must honour to draw a frame correctly.

Link copied to clipboard

The YCbCr to RGB matrix. Values match FFmpeg's AVColorSpace.

Link copied to clipboard

The colour primaries. Values match FFmpeg's AVColorPrimaries.

Link copied to clipboard

The transfer function, meaning the gamma curve. Values match FFmpeg's AVColorTransferCharacteristic.

Link copied to clipboard
expect class CopyStream

An output stream fed by stream-copy. Opaque handle; packets flow through Remuxer/Transcoder.

actual class CopyStream

An output stream fed by stream-copy. Opaque handle; packets flow through Remuxer/Transcoder.

actual class CopyStream

An output stream fed by stream-copy. Opaque handle; packets flow through Remuxer/Transcoder.

actual class CopyStream

An output stream fed by stream-copy. Opaque handle; packets flow through Remuxer/Transcoder.

Link copied to clipboard

What decoding does when FFmpeg reports damaged data.

Link copied to clipboard
data class Disposition(val default: Boolean = false, val forced: Boolean = false, val hearingImpaired: Boolean = false, val visualImpaired: Boolean = false, val attachedPicture: Boolean = false)

What a container says a stream is for.

Link copied to clipboard
expect object FFmpeg

Static facade for global FFmpeg state: version info, build flags and capability probing.

actual object FFmpeg

Static facade for global FFmpeg state: version info, build flags and capability probing.

actual object FFmpeg

Static facade for global FFmpeg state: version info, build flags and capability probing.

actual object FFmpeg

Static facade for global FFmpeg state: version info, build flags and capability probing.

actual object FFmpeg

The real web backend, over the generated binding.

Link copied to clipboard
sealed class FFmpegError

Every KiteFFmpeg failure surfaces as FFmpegException wrapping a typed FFmpegError.

Link copied to clipboard

The single exception type KiteFFmpeg throws for FFmpeg-related failures. Inspect error for the semantic category and code for the raw AVERROR_* value.

Link copied to clipboard
class FFmpegIdentity(val status: Int, val bypassed: Boolean, val bypassedStatus: Int, val cAbiVersion: String, val libraries: List<FFmpegLibraryIdentity>, val configurationsAgree: Boolean, val configurationsDisagreed: List<String>, val buildFFmpegRef: String, val buildLicenseFlavour: String, val buildProvisioningDir: String, val runtimeVersionInfo: String, val runtimeLicense: String, val provisioning: String)

The FFmpeg identity report: what this build was compiled against, what it is linked to, and whether the two are compatible.

Link copied to clipboard
class FFmpegLibraryIdentity(val name: String, val headerMajor: Int, val headerMinor: Int, val headerMicro: Int, val runtimeMajor: Int, val runtimeMinor: Int, val runtimeMicro: Int, val verdict: String)

One FFmpeg library's two version columns and the verdict comparing them.

Link copied to clipboard
expect class FilterGraph : AutoCloseable

A compiled libavfilter graph. Build with FilterGraph.buildVideo / FilterGraph.buildAudio (single input) or buildVideoMulti / buildAudioMulti (N inputs: overlay, amix, …). Feed frames through process (single input) or feedInput (any input). Close it when done.

actual class FilterGraph : AutoCloseable

A compiled libavfilter graph. Build with FilterGraph.buildVideo / FilterGraph.buildAudio (single input) or buildVideoMulti / buildAudioMulti (N inputs: overlay, amix, …). Feed frames through process (single input) or feedInput (any input). Close it when done.

actual class FilterGraph : AutoCloseable

A compiled libavfilter graph. Build with FilterGraph.buildVideo / FilterGraph.buildAudio (single input) or buildVideoMulti / buildAudioMulti (N inputs: overlay, amix, …). Feed frames through process (single input) or feedInput (any input). Close it when done.

actual class FilterGraph : AutoCloseable

A compiled libavfilter graph. Build with FilterGraph.buildVideo / FilterGraph.buildAudio (single input) or buildVideoMulti / buildAudioMulti (N inputs: overlay, amix, …). Feed frames through process (single input) or feedInput (any input). Close it when done.

Link copied to clipboard
expect class Frame : AutoCloseable

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

actual class Frame : AutoCloseable

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

actual class Frame : AutoCloseable

AVFrame-backed Frame implementation. The native pointer (nativeFrame) is internal: users go through info / copyPlanesToByteArray; the filter graph & encoder modules in this package read the pointer directly for zero-copy hand-offs.

actual class Frame : AutoCloseable

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

actual class Frame : AutoCloseable

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

Link copied to clipboard
data class FrameInfo(val streamIndex: Int, val type: MediaType, val pts: Long, val timeBase: Rational, val width: Int = 0, val height: Int = 0, val pixelFormat: PixelFormat = PixelFormat.None, val sampleCount: Int = 0, val sampleRate: Int = 0, val channelCount: Int = 0, val sampleFormat: SampleFormat = SampleFormat.None, val channelLayoutMask: Long? = null, val duration: Long = 0, val isKeyframe: Boolean = false, val color: ColorInfo = ColorInfo.Unspecified, val sampleAspectRatio: Rational = Rational(1, 1), val isHardware: Boolean = false)

Immutable per-frame metadata snapshot: no native handle, safe to hold forever.

Link copied to clipboard

A hardware acceleration a decoder can be opened with (KiteFFmpeg window 3).

Link copied to clipboard
@RequiresOptIn(level = RequiresOptIn.Level.ERROR, message = "Low-level KiteFFmpeg API: native-backed handles, manual lifetimes, and no stability promise. Opt in with @OptIn(KiteFFmpegLowLevelApi::class) if you are building a player or another pipeline that must drive demuxing and decoding as separate stages.")
annotation class KiteFFmpegLowLevelApi

Marks API that hands out opaque native-backed owners, manual lifetimes, or a stage of the pipeline that the caller must drive itself.

Link copied to clipboard

Loads the codec, which on the web is a separate wasm module fetched over the network.

Link copied to clipboard

Media bytes from caller code instead of a path: the custom I/O door. A player streams through its own HTTP client with its own TLS and auth, reads from an encrypted store, a torrent, a cache, or a byte array it already holds, and FFmpeg demuxes those bytes exactly as it would a file's.

Link copied to clipboard
data class MediaInfo(val durationMicros: Long?, val formatName: String, val metadata: Map<String, String>, val chapters: List<Chapter>)

The container-level facts in one value (KD-5): what a player's media screen shows before any stream is selected. Assembled from the source's own members, so it can never disagree with them.

Link copied to clipboard
expect class MediaSink : AutoCloseable

An open output file (muxer). Add every encoder first, video and audio, because the muxer's header freezes the stream list. Then push frames through the encoders. Close the sink to write the trailer and flush buffers.

actual class MediaSink : AutoCloseable

An open output file (muxer). Add every encoder first, video and audio, because the muxer's header freezes the stream list. Then push frames through the encoders. Close the sink to write the trailer and flush buffers.

actual class MediaSink : AutoCloseable

An open output file (muxer). Add every encoder first, video and audio, because the muxer's header freezes the stream list. Then push frames through the encoders. Close the sink to write the trailer and flush buffers.

actual class MediaSink : AutoCloseable

An open output file (muxer). Add every encoder first, video and audio, because the muxer's header freezes the stream list. Then push frames through the encoders. Close the sink to write the trailer and flush buffers.

Link copied to clipboard
expect class MediaSource : AutoCloseable

An opened input: a local file or a URL. It owns the container cursor and per-stream resources, and closing it releases them all. Confine it to one coroutine context, because the underlying media objects are not safe to call concurrently.

actual class MediaSource : AutoCloseable

An opened input: a local file or a URL. It owns the container cursor and per-stream resources, and closing it releases them all. Confine it to one coroutine context, because the underlying media objects are not safe to call concurrently.

actual class MediaSource : AutoCloseable

An opened input: a local file or a URL. It owns the container cursor and per-stream resources, and closing it releases them all. Confine it to one coroutine context, because the underlying media objects are not safe to call concurrently.

actual class MediaSource : AutoCloseable

An opened input: a local file or a URL. It owns the container cursor and per-stream resources, and closing it releases them all. Confine it to one coroutine context, because the underlying media objects are not safe to call concurrently.

actual class MediaSource : AutoCloseable

An open container, over the codec module.

Link copied to clipboard

What kind of data flows on a stream / through a codec / out of a filter graph.

Link copied to clipboard
expect class Packet : AutoCloseable

A demuxed packet the caller owns.

actual class Packet : AutoCloseable

A demuxed packet the caller owns.

actual class Packet : AutoCloseable

A demuxed packet the caller owns.

actual class Packet : AutoCloseable

A demuxed packet the caller owns.

actual class Packet : AutoCloseable

A demuxed packet the caller owns.

Link copied to clipboard

Reads owned packets from one MediaSource cursor under the caller's control. This is the demuxing half of a player, kept separate from decoding so audio and video decoding can proceed independently and a seek can replace the caller's queued generation explicitly.

Reads owned packets from one MediaSource cursor under the caller's control. This is the demuxing half of a player, kept separate from decoding so audio and video decoding can proceed independently and a seek can replace the caller's queued generation explicitly.

Reads packets from a container, one at a time, under the caller's control.

Reads owned packets from one MediaSource cursor under the caller's control. This is the demuxing half of a player, kept separate from decoding so audio and video decoding can proceed independently and a seek can replace the caller's queued generation explicitly.

Reads owned packets from one MediaSource cursor under the caller's control. This is the demuxing half of a player, kept separate from decoding so audio and video decoding can proceed independently and a seek can replace the caller's queued generation explicitly.

Link copied to clipboard
value class PixelFormat(val name: String)

The pixel format of a video frame, named exactly as FFmpeg names it (yuv420p, nv12, …). The platform bridge translates the name to an AV_PIX_FMT_* value.

Link copied to clipboard

FFmpeg's AVRational: an exact fraction. Use it for time-bases, frame rates and aspect ratios. Float conversion is lossy; do all arithmetic on the rational form when possible.

Link copied to clipboard
expect object Remuxer

Lossless container rewrite: ffmpeg -c copy. Packets move from input to output without touching a decoder or encoder, so a full-length movie remuxes in seconds and bit-exact quality is preserved. Use it to change containers (mp4 → mkv), strip streams, cut on keyframes, or re-wrap after a download.

actual object Remuxer

Lossless container rewrite: ffmpeg -c copy. Packets move from input to output without touching a decoder or encoder, so a full-length movie remuxes in seconds and bit-exact quality is preserved. Use it to change containers (mp4 → mkv), strip streams, cut on keyframes, or re-wrap after a download.

actual object Remuxer

Lossless container rewrite: ffmpeg -c copy. Packets move from input to output without touching a decoder or encoder, so a full-length movie remuxes in seconds and bit-exact quality is preserved. Use it to change containers (mp4 → mkv), strip streams, cut on keyframes, or re-wrap after a download.

actual object Remuxer

Lossless container rewrite: ffmpeg -c copy. Packets move from input to output without touching a decoder or encoder, so a full-length movie remuxes in seconds and bit-exact quality is preserved. Use it to change containers (mp4 → mkv), strip streams, cut on keyframes, or re-wrap after a download.

Link copied to clipboard
value class SampleFormat(val name: String)

Audio sample format. Planar variants store each channel in its own plane; packed variants interleave channels. s16 / s16p is the most common decoder output.

Link copied to clipboard

Which way a seek may land relative to the target.

Which way a seek may land relative to the target.

Which way a seek may land relative to the target.

Which way a seek may land relative to the target.

Which way a seek may land relative to the target.

Link copied to clipboard

One decoder driven explicitly by the caller.

One decoder driven explicitly by the caller.

One decoder, driven by the caller.

One decoder driven explicitly by the caller.

One decoder driven explicitly by the caller.

Link copied to clipboard
data class StreamInfo(val index: Int, val type: MediaType, val codec: CodecId, val timeBase: Rational, val durationMicros: Long?, val bitrateBps: Long?, val video: VideoStreamInfo? = null, val audio: AudioStreamInfo? = null, val metadata: Map<String, String> = emptyMap(), val disposition: Disposition = Disposition.None, val rotationDegrees: Int = 0, val startTimeMicros: Long = 0, val codecExtradata: ByteArray? = null)

Read-only snapshot of an input stream's metadata.

Link copied to clipboard
data class TranscodeProgress(val framesEncoded: Long, val outputMicros: Long, val percent: Double?)

Progress snapshot delivered during Transcoder.transcode.

Link copied to clipboard
expect object Transcoder

High-level pipeline: open input → decode → optionally filter → encode → mux. The equivalent of ffmpeg -ss 12 -to 45 -i in.mp4 -vf "scale=…" -c:v libx264 -c:a aac out.mp4 as one Kotlin call with proper cancellation and typed errors.

actual object Transcoder

High-level pipeline: open input → decode → optionally filter → encode → mux. The equivalent of ffmpeg -ss 12 -to 45 -i in.mp4 -vf "scale=…" -c:v libx264 -c:a aac out.mp4 as one Kotlin call with proper cancellation and typed errors.

actual object Transcoder

High-level pipeline: open input → decode → optionally filter → encode → mux. The equivalent of ffmpeg -ss 12 -to 45 -i in.mp4 -vf "scale=…" -c:v libx264 -c:a aac out.mp4 as one Kotlin call with proper cancellation and typed errors.

actual object Transcoder

High-level pipeline: open input → decode → optionally filter → encode → mux. The equivalent of ffmpeg -ss 12 -to 45 -i in.mp4 -vf "scale=…" -c:v libx264 -c:a aac out.mp4 as one Kotlin call with proper cancellation and typed errors.

Link copied to clipboard
data class Versions(val avutil: String, val avcodec: String, val avformat: String, val avfilter: String, val swscale: String, val swresample: String, val avutilHeader: String, val avcodecHeader: String, val avformatHeader: String, val avfilterHeader: String, val swscaleHeader: String, val swresampleHeader: String)

Per-library version triplets, both columns.

Link copied to clipboard

One configured and opened video encoder. Pull from a Flow<Frame> via drive. That call pushes each frame into the encoder, pulls packets, hands them to the sink's muxer, and flushes when the flow completes.

One configured and opened video encoder. Pull from a Flow<Frame> via drive. That call pushes each frame into the encoder, pulls packets, hands them to the sink's muxer, and flushes when the flow completes.

One configured and opened video encoder. Pull from a Flow<Frame> via drive. That call pushes each frame into the encoder, pulls packets, hands them to the sink's muxer, and flushes when the flow completes.

One configured and opened video encoder. Pull from a Flow<Frame> via drive. That call pushes each frame into the encoder, pulls packets, hands them to the sink's muxer, and flushes when the flow completes.

Link copied to clipboard
data class VideoEncoderSpec(val codec: CodecId, val width: Int, val height: Int, val pixelFormat: PixelFormat = PixelFormat.Yuv420p, val frameRate: Rational, val bitrateBps: Long, val keyframeIntervalFrames: Int = (frameRate.asDouble * 2).toInt().coerceAtLeast(1), val options: Map<String, String> = emptyMap())
Link copied to clipboard
data class VideoInput(val width: Int, val height: Int, val pixelFormat: PixelFormat, val timeBase: Rational, val frameRate: Rational, val sampleAspectRatio: Rational = Rational(1, 1))

Per-input description for FilterGraph.buildVideoMulti.

Link copied to clipboard
data class VideoStreamInfo(val width: Int, val height: Int, val pixelFormat: PixelFormat, val frameRate: Rational, val sampleAspectRatio: Rational, val color: ColorInfo = ColorInfo.Unspecified, val vp9: Vp9CodecInfo? = null)
Link copied to clipboard
Link copied to clipboard

VP9 chroma plane resolution. Chroma siting remains in ColorInfo.chromaLocation.

Link copied to clipboard
data class Vp9CodecInfo(val profile: Vp9Profile?, val level: Vp9Level?, val bitDepth: Vp9BitDepth?, val chromaSubsampling: Vp9ChromaSubsampling?)

Codec-level VP9 declarations copied from FFmpeg's probed stream parameters.

Link copied to clipboard

VP9 level code as carried by FFmpeg (10 means level 1.0, 41 means level 4.1, etc.).

Link copied to clipboard
Link copied to clipboard

Converts video frames to RGBA without the pixels ever entering Kotlin memory.

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

The assembled container-level view. Reads only members the source already exposes.

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
fun Flow<Frame>.bufferFrames(capacity: Int = Channel.BUFFERED, context: CoroutineContext = EmptyCoroutineContext): Flow<Frame>

Buffers a frame flow without stranding the frames it is still holding.

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.