Transcoder

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.

All selected streams are demuxed in a single pass. Their packets are interleaved into the output as they are produced, so memory use stays constant regardless of input length.

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.

All selected streams are demuxed in a single pass. Their packets are interleaved into the output as they are produced, so memory use stays constant regardless of input length.

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.

All selected streams are demuxed in a single pass. Their packets are interleaved into the output as they are produced, so memory use stays constant regardless of input length.

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.

All selected streams are demuxed in a single pass. Their packets are interleaved into the output as they are produced, so memory use stays constant regardless of input length.

Functions

Link copied to clipboard
expect suspend fun transcode(input: String, output: String, spec: VideoEncoderSpec? = null, videoFilter: String? = null, videoCopy: Boolean = false, audioSpec: AudioEncoderSpec? = null, audioFilter: String? = null, audioCopy: Boolean = false, subtitleCopy: Boolean = false, subtitleCodec: CodecId? = null, startMicros: Long = 0, endMicros: Long = Long.MAX_VALUE, metadata: Map<String, String> = emptyMap(), dispatcher: CoroutineDispatcher? = null, onProgress: (TranscodeProgress) -> Unit? = null)

Run a transcode end-to-end. Suspends until done.

expect suspend fun transcode(input: String, inputOptions: Map<String, String>, output: String, spec: VideoEncoderSpec? = null, videoFilter: String? = null, videoCopy: Boolean = false, audioSpec: AudioEncoderSpec? = null, audioFilter: String? = null, audioCopy: Boolean = false, subtitleCopy: Boolean = false, subtitleCodec: CodecId? = null, startMicros: Long = 0, endMicros: Long = Long.MAX_VALUE, metadata: Map<String, String> = emptyMap(), dispatcher: CoroutineDispatcher? = null, onProgress: (TranscodeProgress) -> Unit? = null)

transcode with pre-open options for input, applied the way MediaSource.open applies them. On Android this reads a file the user picked without copying it: pass "fd:" as input and the descriptor number as the fd option. Every other parameter is as in the path overload.

expect suspend fun transcode(input: () -> MediaByteSource, output: MediaByteSink, format: String, outputOptions: Map<String, String> = emptyMap(), spec: VideoEncoderSpec? = null, videoFilter: String? = null, videoCopy: Boolean = false, audioSpec: AudioEncoderSpec? = null, audioFilter: String? = null, audioCopy: Boolean = false, subtitleCopy: Boolean = false, subtitleCodec: CodecId? = null, startMicros: Long = 0, endMicros: Long = Long.MAX_VALUE, metadata: Map<String, String> = emptyMap(), dispatcher: CoroutineDispatcher? = null, onProgress: (TranscodeProgress) -> Unit? = null)

transcode from bytes the caller supplies into bytes the caller keeps, with no path at either end. Every other parameter is as in the path overload.

actual suspend fun transcode(input: String, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)
actual suspend fun transcode(input: String, inputOptions: Map<String, String>, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)
actual suspend fun transcode(input: () -> MediaByteSource, output: MediaByteSink, format: String, outputOptions: Map<String, String>, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)
actual suspend fun transcode(input: String, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

Run a transcode end-to-end. Suspends until done.

actual suspend fun transcode(input: String, inputOptions: Map<String, String>, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

transcode with pre-open options for input, applied the way MediaSource.open applies them. On Android this reads a file the user picked without copying it: pass "fd:" as input and the descriptor number as the fd option. Every other parameter is as in the path overload.

actual suspend fun transcode(input: () -> MediaByteSource, output: MediaByteSink, format: String, outputOptions: Map<String, String>, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

transcode from bytes the caller supplies into bytes the caller keeps, with no path at either end. Every other parameter is as in the path overload.

actual suspend fun transcode(input: String, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

Run a transcode end-to-end. Suspends until done.

actual suspend fun transcode(input: String, inputOptions: Map<String, String>, output: String, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

transcode with pre-open options for input, applied the way MediaSource.open applies them. On Android this reads a file the user picked without copying it: pass "fd:" as input and the descriptor number as the fd option. Every other parameter is as in the path overload.

actual suspend fun transcode(input: () -> MediaByteSource, output: MediaByteSink, format: String, outputOptions: Map<String, String>, spec: VideoEncoderSpec?, videoFilter: String?, videoCopy: Boolean, audioSpec: AudioEncoderSpec?, audioFilter: String?, audioCopy: Boolean, subtitleCopy: Boolean, subtitleCodec: CodecId?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, dispatcher: CoroutineDispatcher?, onProgress: (TranscodeProgress) -> Unit?)

transcode from bytes the caller supplies into bytes the caller keeps, with no path at either end. Every other parameter is as in the path overload.