Package-level declarations

Types

Link copied to clipboard
interface AsyncCloseable

A resource whose release may wait.

Link copied to clipboard

One decoded frame of an AsyncMediaRuntime. It is the suspending form of Frame. info was read when the frame was made. Everything that reads the frame's data waits for the lane.

Link copied to clipboard
fun interface AsyncMediaByteOpener

Opens the other addresses that media read through an AsyncMediaByteSource refers to, such as the segments and keys of an HLS playlist. It is the suspending form of MediaByteOpener.

Link copied to clipboard

Media bytes from caller code that may answer later: a Fetch response, a network client, a cache. It is the suspending form of MediaByteSource, opened through AsyncMediaRuntime.open.

Link copied to clipboard

What a container says about itself, as one snapshot. It never changes: an operation that changes the container publishes a new snapshot in AsyncMediaSource.info.

Link copied to clipboard

Reads media whose bytes may answer later, from an AsyncMediaByteSource.

Link copied to clipboard

An open container of an AsyncMediaRuntime. It is the suspending form of MediaSource, and its members mean what the members of the same name mean there.

Link copied to clipboard

One packet of an AsyncMediaRuntime. It is the suspending form of Packet. Every property was read when the packet was made, so a getter never waits and never enters FFmpeg.

Link copied to clipboard

Reads the packets of an AsyncMediaSource. It is the suspending form of PacketReader. A source has one read position, so it has one open reader at a time.

Link copied to clipboard

Decodes the packets of one stream. It is the suspending form of StreamDecoder.

Link copied to clipboard

Decodes subtitle packets. It is the suspending form of SubtitleDecoder.

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(), val channelLayoutMask: Long? = null, val encoder: EncoderId? = null)

What an audio encoder writes: the format, the rate, the channels and the sample format. MediaSink.addAudioEncoder opens an encoder from it, and Transcoder.transcode takes one as its audio spec.

Link copied to clipboard
data class AudioInput(val sampleRate: Int, val sampleFormat: SampleFormat, val channels: Int, val timeBase: Rational, val channelLayoutMask: Long? = null)

Per-input description for FilterGraph.buildAudioMulti.

Link copied to clipboard
data class AudioSpec(val sampleRate: Int, val channels: Int, val sampleFormat: SampleFormat, val channelLayoutMask: Long? = null)

A sample rate, a channel count and a sample format: the shape of one audio stream.

Link copied to clipboard
data class AudioStreamInfo(val sampleRate: Int, val channels: Int, val sampleFormat: SampleFormat, val channelLayoutMask: Long? = null)

What the container declares about an audio stream.

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, 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

Turns the closed captions that video frames carry into timed text (#179): the bytes Frame.closedCaptions gives, three per caption pair, as broadcast H.264, HEVC and MPEG-2 carry them in the video stream itself. A caption track stored on its own, such as a MOV c608 track, is a subtitle stream instead and decodes through MediaSource.openSubtitleDecoder.

Turns the closed captions that video frames carry into timed text (#179): the bytes Frame.closedCaptions gives, three per caption pair, as broadcast H.264, HEVC and MPEG-2 carry them in the video stream itself. A caption track stored on its own, such as a MOV c608 track, is a subtitle stream instead and decodes through MediaSource.openSubtitleDecoder.

Turns the closed captions that video frames carry into timed text (#179): the bytes Frame.closedCaptions gives, three per caption pair, as broadcast H.264, HEVC and MPEG-2 carry them in the video stream itself. A caption track stored on its own, such as a MOV c608 track, is a subtitle stream instead and decodes through MediaSource.openSubtitleDecoder.

Turns the closed captions that video frames carry into timed text (#179): the bytes Frame.closedCaptions gives, three per caption pair, as broadcast H.264, HEVC and MPEG-2 carry them in the video stream itself. A caption track stored on its own, such as a MOV c608 track, is a subtitle stream instead and decodes through MediaSource.openSubtitleDecoder.

Turns the closed captions that video frames carry into timed text (#179): the bytes Frame.closedCaptions gives, three per caption pair, as broadcast H.264, HEVC and MPEG-2 carry them in the video stream itself. A caption track stored on its own, such as a MOV c608 track, is a subtitle stream instead and decodes through MediaSource.openSubtitleDecoder.

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

A bitstream format, by FFmpeg's codec name (h264, aac, av1): what a stream carries, whichever implementation wrote it or reads it. EncoderId and DecoderId name the implementations, and FFmpeg.codecOf, FFmpeg.encodersFor and FFmpeg.decodersFor map between the two.

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
data class ContentLightLevel(val maxCll: Int, val maxFall: Int)

Content light level, as CTA-861.3 describes it: maxCll is the brightest single pixel and maxFall the brightest frame average, both in candelas per square metre.

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
value class DecoderId(val name: String)

One decoder, by its FFmpeg name (libdav1d, h264_mediacodec): an implementation that reads a CodecId. MediaSource.openDecoder takes one to pick a decoder other than FFmpeg's default.

Link copied to clipboard
data class DisplayPrimaries(val redX: Rational, val redY: Rational, val greenX: Rational, val greenY: Rational, val blueX: Rational, val blueY: Rational, val whiteX: Rational, val whiteY: Rational)

Red, green and blue primaries and a white point, as CIE 1931 xy chromaticity coordinates.

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, val descriptions: Boolean = false, val comment: Boolean = false)

What a container says a stream is for.

Link copied to clipboard

The fields worth comparing: the ones a caller allocates against before decoding starts.

Link copied to clipboard
data class DolbyVisionBrightness(val minPq: Int, val averagePq: Int, val maxPq: Int)

The brightness of a scene, as the RPU's level 1 metadata states it: the darkest, the average and the brightest level, each as a 12-bit PQ code. A tone mapper that knows the scene's peak can keep more of a dark scene than one that only knows the peak of the whole title.

Link copied to clipboard
data class DolbyVisionColor(val dmMetadataId: Int, val sceneRefresh: Int, val yccToRgbMatrix: List<Rational>, val yccToRgbOffset: List<Rational>, val rgbToLmsMatrix: List<Rational>, val signalEotf: Int, val signalEotfParam0: Int, val signalEotfParam1: Int, val signalEotfParam2: Long, val signalBitDepth: Int, val signalColorSpace: Int, val signalChromaFormat: Int, val signalFullRange: Int, val sourceMinPq: Int, val sourceMaxPq: Int, val sourceDiagonal: Int)

The colour of the reshaped signal, FFmpeg's AVDOVIColorMetadata, which FFmpeg fills with its defaults when the RPU carries none of its own.

Link copied to clipboard

The Dolby Vision composition of one frame, which turns the base layer and its RPU into an ordinary HDR10 picture: 10-bit 4:2:0 in BT.2020 with the PQ curve, limited range, the source's range as its mastering display, and no Dolby Vision metadata left on it. Every renderer that can show HDR10 can then show it.

Link copied to clipboard
data class DolbyVisionConfig(val versionMajor: Int, val versionMinor: Int, val profile: Int, val level: Int, val hasRpu: Boolean, val hasEnhancementLayer: Boolean, val hasBaseLayer: Boolean, val baseLayerCompatibility: Int)

The Dolby Vision configuration record a stream declares, as the container's dvcC, dvvC or dvwC box, or Matroska's block addition mapping, carries it.

Link copied to clipboard
data class DolbyVisionCurve(val pivots: List<Int>, val pieces: List<DolbyVisionPiece>)

The reshaping of one component: a curve in pieces between pivots, each piece a polynomial or an MMR mapping, FFmpeg's AVDOVIReshapingCurve.

Link copied to clipboard
data class DolbyVisionMapping(val vdrRpuId: Int, val mappingColorSpace: Int, val mappingChromaFormat: Int, val curves: List<DolbyVisionCurve>, val nonlinearQuantization: DolbyVisionNonlinearQuantization?, val xPartitions: Int, val yPartitions: Int)

How an RPU maps each component of the base layer, FFmpeg's AVDOVIDataMapping.

Link copied to clipboard
data class DolbyVisionMetadata(val baseLayerBitDepth: Int, val usesEnhancementLayer: Boolean, val sourceMinPq: Int, val sourceMaxPq: Int, val sceneBrightness: DolbyVisionBrightness?)

The Dolby Vision metadata of one decoded frame, read from the RPU that FFmpeg's decoder parsed and attached to it.

Link copied to clipboard
data class DolbyVisionNlqComponent(val offset: Int, val vdrInMax: Long, val deadZoneSlope: Long, val deadZoneThreshold: Long)

The inverse quantization of one component, FFmpeg's AVDOVINLQParams.

Link copied to clipboard
data class DolbyVisionNonlinearQuantization(val pivots: List<Int>?, val components: List<DolbyVisionNlqComponent>)

The linear dead-zone inverse quantization that restores an enhancement layer's residual, the one method FFmpeg reads, from FFmpeg's AVDOVIDataMapping.

Link copied to clipboard
sealed class DolbyVisionPiece

The mapping of one span of a DolbyVisionCurve.

Link copied to clipboard
data class DolbyVisionRpu(val header: DolbyVisionRpuHeader, val mapping: DolbyVisionMapping, val color: DolbyVisionColor)

Everything the RPU of one decoded frame says about turning its base layer into the graded picture, as FFmpeg's decoder parsed it into AVDOVIMetadata: the header, the reshaping and inverse quantization in mapping, and the matrices and levels of the signal in color.

Link copied to clipboard
data class DolbyVisionRpuHeader(val rpuType: Int, val rpuFormat: Int, val vdrRpuProfile: Int, val vdrRpuLevel: Int, val chromaResamplingExplicitFilter: Boolean, val coefficientDataType: Int, val coefficientLog2Denominator: Int, val vdrRpuNormalizedIdc: Int, val baseLayerFullRange: Boolean, val baseLayerBitDepth: Int, val enhancementLayerBitDepth: Int, val vdrBitDepth: Int, val spatialResamplingFilter: Boolean, val enhancementLayerSpatialResamplingFilter: Boolean, val disableResidual: Boolean)

The header of an RPU, FFmpeg's AVDOVIRpuDataHeader, each field under its name there. Its two ext_mapping_idc fields are left out, because nothing in FFmpeg but its RPU encoder reads them.

Link copied to clipboard

Where a container's length came from, as FFmpeg records it in AVFormatContext.duration_estimation_method. See MediaSource.durationOrigin.

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

One encoder, by its FFmpeg name (libx264, h264_videotoolbox, aac): an implementation that produces a CodecId. FFmpeg.codecOf says which format, and FFmpeg.encodersFor lists the encoders a build has for a format.

Link copied to clipboard
sealed interface FeedResult

What a FilterGraph.feedInput or FilterGraph.flushInput call produced, and what the graph needs next.

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

A family of FFmpeg components that FFmpeg.components lists.

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

How severe an FFmpeg log line is, from the most severe to the least.

Link copied to clipboard
data class FFmpegLogLine(val level: FFmpegLogLevel, val component: String, val message: String)

One line FFmpeg logged, as FFmpegException.logged keeps it (#170).

Link copied to clipboard
fun interface FFmpegLogSink

Receives FFmpeg's own log lines, as installed with FFmpeg.setLogSink.

Link copied to clipboard
enum class FieldOrder : Enum<FieldOrder>

How a video stream's fields are ordered, in DISPLAY order.

Link copied to clipboard

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. feedInput and flushInput answer with a FeedResult, which names the input a graph with several inputs waits for.

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

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.

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, val hdr: HdrMetadata? = null)

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.

Link copied to clipboard
data class HdrMetadata(val masteringDisplay: MasteringDisplay? = null, val contentLight: ContentLightLevel? = null)

The static HDR metadata a stream carries beside its colour tags. A tone mapper uses it to learn how bright the content and the display it was graded on actually were, instead of assuming.

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
data class LuminanceRange(val min: Rational, val max: Rational)

A luminance range in candelas per square metre.

Link copied to clipboard
data class MasteringDisplay(val primaries: DisplayPrimaries?, val luminance: LuminanceRange?)

The mastering display an HDR stream was graded on, as SMPTE ST 2086 describes it. Either half may be missing, because a stream may declare one without the other.

Link copied to clipboard
data class MatroskaChapter(val uid: Long, val stringUid: String?, val startNanos: Long, val endNanos: Long?, val isHidden: Boolean, val isEnabled: Boolean, val segmentUid: String?, val segmentEditionUid: Long?, val skipType: MatroskaSkipType?, val names: List<MatroskaName>, val chapters: List<MatroskaChapter>)

One ChapterAtom.

Link copied to clipboard
data class MatroskaEdition(val uid: Long?, val isDefault: Boolean, val isHidden: Boolean, val isOrdered: Boolean, val names: List<MatroskaName>, val chapters: List<MatroskaChapter>)

One EditionEntry: a set of chapters, such as one cut of a film.

Link copied to clipboard
data class MatroskaName(val text: String, val languages: List<String>, val countries: List<String>)

One name of an edition or chapter in its languages.

Link copied to clipboard
data class MatroskaSegment(val uid: String?, val filename: String?, val previousUid: String?, val previousFilename: String?, val nextUid: String?, val nextFilename: String?, val families: List<String>, val editions: List<MatroskaEdition>)

What a Matroska file says about its own segment, its editions and their chapters, read as RFC 9559 defines them (#173).

Link copied to clipboard

What a chapter is, from its ChapterSkipType, so that a player can offer to skip it.

Link copied to clipboard
fun interface MediaByteOpener

Opens the other addresses that media read through a MediaByteSource refers to.

Link copied to clipboard

Where an output's bytes go instead of a path: the custom I/O door for writing, and the output half of MediaByteSource. An in-memory buffer, encrypted storage, a virtual file system or an upload stream takes the bytes a muxer writes, through MediaSink.open.

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: 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
data class MediaProbe(val formatName: String, val durationMicros: Long?, val startTimeMicros: Long, val isSeekable: Boolean, val bitrateBps: Long?, val metadata: Map<String, String>, val chapters: List<Chapter>, val streams: List<StreamInfo>, val programs: List<Program> = emptyList(), val matroska: MatroskaSegment? = null)

Everything a container says about itself, read in one call and with nothing left open.

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
enum class MediaType : Enum<MediaType>

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

Link copied to clipboard

A cancel request that can reach MediaSource.open while it runs.

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
data class Program(val id: Int, val number: Int?, val streamIndexes: List<Int>, val metadata: Map<String, String> = emptyMap())

One programme of a source: a set of its streams that play together (#148).

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
expect class Resampler(input: AudioSpec, output: AudioSpec) : AutoCloseable

Converts audio frames between sample rates, channel counts and sample formats with FFmpeg's libswresample.

actual class Resampler(val input: AudioSpec, val output: AudioSpec) : AutoCloseable

Converts audio frames between sample rates, channel counts and sample formats with FFmpeg's libswresample.

actual class Resampler(val input: AudioSpec, val output: AudioSpec) : AutoCloseable

Converts audio frames between sample rates, channel counts and sample formats with FFmpeg's libswresample.

actual class Resampler(val input: AudioSpec, val output: AudioSpec) : AutoCloseable

Converts audio frames between sample rates, channel counts and sample formats with FFmpeg's libswresample.

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
expect enum class SeekDirection : Enum<SeekDirection>

Which way a seek may land relative to the target.

actual enum class SeekDirection : Enum<SeekDirection>

Which way a seek may land relative to the target.

actual enum class SeekDirection : Enum<SeekDirection>

Which way a seek may land relative to the target.

actual enum class SeekDirection : Enum<SeekDirection>

Which way a seek may land relative to the target.

actual enum class SeekDirection : Enum<SeekDirection>

Which way a seek may land relative to the target.

Link copied to clipboard
data class SphericalMapping(val projection: SphericalProjection, val yaw: Double, val pitch: Double, val roll: Double)

How a stream's pictures map onto a sphere around the viewer, as its container states it: in MP4 or MOV through Google's spherical video boxes or Apple's video extension box, in Matroska through the track's Projection element. FFmpeg reads it into the stream's AVSphericalMapping and applies none of it, so a renderer that draws the picture flat shows a 360 degree video as a stretched panorama.

Link copied to clipboard
sealed class SphericalProjection

How a picture covers the sphere, FFmpeg's AVSphericalProjection.

Link copied to clipboard
data class Stereo3D(val type: Stereo3DType, val inverted: Boolean, val view: Stereo3DView, val primaryEye: StereoEye?, val baselineMicrometres: Long?, val horizontalDisparityAdjustment: Rational, val horizontalFieldOfView: Rational?)

How a stream's pictures hold the views of two eyes, as its container states it: in MP4 or MOV through the stereoscopic video box or Apple's video extension box, in Matroska through the track's StereoMode. FFmpeg reads it into the stream's AVStereo3D and splits nothing, so a renderer that draws the picture whole shows both views side by side or one above the other.

Link copied to clipboard

How two views are packed into each picture, FFmpeg's AVStereo3DType.

Link copied to clipboard

Which views a stream's pictures hold, FFmpeg's AVStereo3DView.

Link copied to clipboard
enum class StereoEye : Enum<StereoEye>

One eye.

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 StreamDivergence(val streamIndex: Int, val field: DivergentField, val declared: String, val decoded: String)

A field where the container's declaration and the decoder's output disagree.

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, val codecProfile: Int? = null, val mirrored: Boolean = false)

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

Link copied to clipboard
data class Subtitle(val startMicros: Long?, val endMicros: Long?, val canvasWidth: Int, val canvasHeight: Int, val images: List<SubtitleImage>, val texts: List<String>)

One decoded subtitle: what to show, where, and when.

Link copied to clipboard

Decodes the packets of one subtitle stream, from MediaSource.openSubtitleDecoder. Read the packets with a PacketReader and hand each one to decode.

Decodes the packets of one subtitle stream, from MediaSource.openSubtitleDecoder. Read the packets with a PacketReader and hand each one to decode.

Decodes the packets of one subtitle stream, from MediaSource.openSubtitleDecoder. Read the packets with a PacketReader and hand each one to decode.

Decodes the packets of one subtitle stream, from MediaSource.openSubtitleDecoder. Read the packets with a PacketReader and hand each one to decode.

Decodes the packets of one subtitle stream, from MediaSource.openSubtitleDecoder. Read the packets with a PacketReader and hand each one to decode.

Link copied to clipboard
class SubtitleImage(val x: Int, val y: Int, val width: Int, val height: Int, val rgba: ByteArray, val forced: Boolean)

One positioned image of a Subtitle, in canvas pixels.

Link copied to clipboard
data class TrackSelector(val preferredAudioLanguages: List<String> = emptyList())

The policy that picks which video and audio stream to play when the caller did not name one.

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
data class VideoCrop(val top: Int, val bottom: Int, val left: Int, val right: Int)

How many rows and columns at each edge of a stream's decoded pictures are not part of the image, as the container says: a Matroska track's PixelCrop elements, or an MP4 track's clean aperture. Encoders use it to show 1080 lines of a 1088-line coded picture, cameras to hide sensor margins, and remuxers to cut black bars without encoding again.

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(), val color: ColorInfo? = null, val sampleAspectRatio: Rational? = null, val hdr: HdrMetadata? = null, val encoder: EncoderId? = null)

What a video encoder writes: the format, the picture size and pixel format, the rate, and the colour, pixel shape and HDR metadata the output declares. MediaSink.addVideoEncoder opens an encoder from it, and Transcoder.transcode takes one as its video spec.

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, val fieldOrder: FieldOrder = FieldOrder.Unknown, val hdr: HdrMetadata? = null, val dolbyVision: DolbyVisionConfig? = null, val crop: VideoCrop? = null, val spherical: SphericalMapping? = null, val stereo3d: Stereo3D? = null)

What the container declares about a video stream.

Link copied to clipboard

Bits per sample in a VP9 stream.

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
enum class Vp9Level : Enum<Vp9Level>

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

Link copied to clipboard
enum class Vp9Profile : Enum<Vp9Profile>

A VP9 profile. number is its number in the VP9 bitstream specification.

Link copied to clipboard
class WebAsyncCodecArtifacts(val jspiUrl: String? = null, val asyncifyUrl: String? = null)

Where an asynchronous runtime's codec modules are served. Give one address or both. The modules are in kiteffmpeg-wasm-js-<version>-web-async.zip of the wasmJs publication.

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

Buffers a flow of AsyncFrame and closes every frame the collector does not receive. It is the suspending form of bufferFrames, which cannot serve here: the close of an AsyncFrame waits for the runtime's lane, and a channel's own hook for a dropped element cannot wait.

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 FilterGraph.Companion.buildAudio(chain: FilterChain, sampleRate: Int, sampleFormat: SampleFormat, channels: Int, timeBase: Rational, outputSampleRate: Int = 0, outputSampleFormat: SampleFormat = SampleFormat.None, outputChannels: Int = 0, channelLayoutMask: Long? = null, outputChannelLayoutMask: Long? = null): FilterGraph

The audio half of buildVideo's chain overload, with the same refusal.

Link copied to clipboard
fun FilterGraph.Companion.buildVideo(chain: FilterChain, width: Int, height: Int, pixelFormat: PixelFormat, timeBase: Rational, frameRate: Rational, sampleAspectRatio: Rational = Rational(1, 1)): FilterGraph

Builds a video graph from a typed FilterChain, refusing before FFmpeg is asked to parse anything when this build lacks one of the chain's filters.

Link copied to clipboard

MediaSource.open over caller-supplied bytes, with typed DemuxOptions.

fun MediaSource.Companion.open(path: String, options: DemuxOptions, interrupt: OpenInterrupt? = null): MediaSource

MediaSource.open with typed DemuxOptions instead of raw option pairs. interrupt behaves as it does on the raw overload; see OpenInterrupt.

Link copied to clipboard

The same over caller-supplied bytes. The source owns io and closes it, so io is spent when this returns, exactly as it would be after an MediaSource.Companion.open and a close.

fun MediaSource.Companion.probe(path: String, options: Map<String, String> = emptyMap()): MediaProbe

Opens path, reads what it says about itself, and closes it again.

Link copied to clipboard
suspend fun <T : AsyncCloseable, R> T.useAsync(block: suspend (T) -> R): R

Runs block with this resource and closes it afterwards, whatever block did. The close runs even when the caller is cancelled. A failure of the close after a failure of block is added to the first as suppressed.

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.