transcode

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, startMicros: Long = 0, endMicros: Long = Long.MAX_VALUE, metadata: Map<String, String> = emptyMap(), onProgress: (TranscodeProgress) -> Unit? = null)

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

Parameters

input

input file path

output

output file path

spec

video encoder spec. Null (with videoCopy false) gives audio-only output and drops any input video. When set but the input has no video stream, this throws.

videoFilter

filter graph description applied to the video stream. Null passes decoded frames straight into the encoder. Requires spec.

videoCopy

stream-copy the video instead of re-encoding (-c:v copy): bit-exact and near-free. Combine it with audioSpec to keep the video and re-encode only the audio. Mutually exclusive with spec/videoFilter. Trimming a copied video stream is keyframe-snapped, not frame-exact.

audioSpec

audio encoder spec. Null (with audioCopy false) drops audio. When set but the input has no audio stream, the output is silently video-only.

audioFilter

filter chain for the audio stream (e.g. volume=0.5,atempo=1.25). Null means plain resample and reformat to what the encoder needs.

audioCopy

stream-copy the audio instead of re-encoding (-c:a copy): bit-exact, near-free. Mutually exclusive with audioSpec/audioFilter.

subtitleCopy

stream-copy every subtitle stream into the output. Works for subtitle codecs the output container accepts (mkv: almost all; mp4: mov_text). Otherwise the muxer raises a typed error.

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros). Output begins at the first frame at or after this point: frame-exact for re-encoded streams, at the preceding keyframe for copied ones. Output timestamps are rebased to zero.

endMicros

trim end, on the same content-relative scale. Demuxing stops once the lead stream passes this.

metadata

container tags written into the output header (title, artist, …)

onProgress

invoked every ~30 encoded video frames (or ~100 audio frames when audio-only) with a TranscodeProgress

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

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

Parameters

input

input file path

output

output file path

spec

video encoder spec. Null (with videoCopy false) gives audio-only output and drops any input video. When set but the input has no video stream, this throws.

videoFilter

filter graph description applied to the video stream. Null passes decoded frames straight into the encoder. Requires spec.

videoCopy

stream-copy the video instead of re-encoding (-c:v copy): bit-exact and near-free. Combine it with audioSpec to keep the video and re-encode only the audio. Mutually exclusive with spec/videoFilter. Trimming a copied video stream is keyframe-snapped, not frame-exact.

audioSpec

audio encoder spec. Null (with audioCopy false) drops audio. When set but the input has no audio stream, the output is silently video-only.

audioFilter

filter chain for the audio stream (e.g. volume=0.5,atempo=1.25). Null means plain resample and reformat to what the encoder needs.

audioCopy

stream-copy the audio instead of re-encoding (-c:a copy): bit-exact, near-free. Mutually exclusive with audioSpec/audioFilter.

subtitleCopy

stream-copy every subtitle stream into the output. Works for subtitle codecs the output container accepts (mkv: almost all; mp4: mov_text). Otherwise the muxer raises a typed error.

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros). Output begins at the first frame at or after this point: frame-exact for re-encoded streams, at the preceding keyframe for copied ones. Output timestamps are rebased to zero.

endMicros

trim end, on the same content-relative scale. Demuxing stops once the lead stream passes this.

metadata

container tags written into the output header (title, artist, …)

onProgress

invoked every ~30 encoded video frames (or ~100 audio frames when audio-only) with a TranscodeProgress

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

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

Parameters

input

input file path

output

output file path

spec

video encoder spec. Null (with videoCopy false) gives audio-only output and drops any input video. When set but the input has no video stream, this throws.

videoFilter

filter graph description applied to the video stream. Null passes decoded frames straight into the encoder. Requires spec.

videoCopy

stream-copy the video instead of re-encoding (-c:v copy): bit-exact and near-free. Combine it with audioSpec to keep the video and re-encode only the audio. Mutually exclusive with spec/videoFilter. Trimming a copied video stream is keyframe-snapped, not frame-exact.

audioSpec

audio encoder spec. Null (with audioCopy false) drops audio. When set but the input has no audio stream, the output is silently video-only.

audioFilter

filter chain for the audio stream (e.g. volume=0.5,atempo=1.25). Null means plain resample and reformat to what the encoder needs.

audioCopy

stream-copy the audio instead of re-encoding (-c:a copy): bit-exact, near-free. Mutually exclusive with audioSpec/audioFilter.

subtitleCopy

stream-copy every subtitle stream into the output. Works for subtitle codecs the output container accepts (mkv: almost all; mp4: mov_text). Otherwise the muxer raises a typed error.

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros). Output begins at the first frame at or after this point: frame-exact for re-encoded streams, at the preceding keyframe for copied ones. Output timestamps are rebased to zero.

endMicros

trim end, on the same content-relative scale. Demuxing stops once the lead stream passes this.

metadata

container tags written into the output header (title, artist, …)

onProgress

invoked every ~30 encoded video frames (or ~100 audio frames when audio-only) with a TranscodeProgress

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

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

Parameters

input

input file path

output

output file path

spec

video encoder spec. Null (with videoCopy false) gives audio-only output and drops any input video. When set but the input has no video stream, this throws.

videoFilter

filter graph description applied to the video stream. Null passes decoded frames straight into the encoder. Requires spec.

videoCopy

stream-copy the video instead of re-encoding (-c:v copy): bit-exact and near-free. Combine it with audioSpec to keep the video and re-encode only the audio. Mutually exclusive with spec/videoFilter. Trimming a copied video stream is keyframe-snapped, not frame-exact.

audioSpec

audio encoder spec. Null (with audioCopy false) drops audio. When set but the input has no audio stream, the output is silently video-only.

audioFilter

filter chain for the audio stream (e.g. volume=0.5,atempo=1.25). Null means plain resample and reformat to what the encoder needs.

audioCopy

stream-copy the audio instead of re-encoding (-c:a copy): bit-exact, near-free. Mutually exclusive with audioSpec/audioFilter.

subtitleCopy

stream-copy every subtitle stream into the output. Works for subtitle codecs the output container accepts (mkv: almost all; mp4: mov_text). Otherwise the muxer raises a typed error.

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros). Output begins at the first frame at or after this point: frame-exact for re-encoded streams, at the preceding keyframe for copied ones. Output timestamps are rebased to zero.

endMicros

trim end, on the same content-relative scale. Demuxing stops once the lead stream passes this.

metadata

container tags written into the output header (title, artist, …)

onProgress

invoked every ~30 encoded video frames (or ~100 audio frames when audio-only) with a TranscodeProgress