remux

expect suspend fun remux(input: String, output: String, streamIndices: List<Int>? = null, startMicros: Long = 0, endMicros: Long = Long.MAX_VALUE, metadata: Map<String, String> = emptyMap(), onProgress: (packetsWritten: Long) -> Unit? = null)

Copy streamIndices (default: every stream the demuxer understands) from input into a fresh container at output. Format inferred from the output extension.

The cut is keyframe-snapped, which is the price of not re-encoding: it starts at the last keyframe at or before startMicros and stops once the first selected stream passes endMicros. Output timestamps are rebased to start at zero.

Bitstream filters are not applied yet, so container pairs that need one (h264-in-mp4 to MPEG-TS Annex B) fail with a muxer error rather than producing a broken file.

Parameters

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros)

endMicros

trim end, on the same content-relative scale

metadata

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

onProgress

invoked every ~100 packets with the running packet count

actual suspend fun remux(input: String, output: String, streamIndices: List<Int>?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, onProgress: (packetsWritten: Long) -> Unit?)

Copy streamIndices (default: every stream the demuxer understands) from input into a fresh container at output. Format inferred from the output extension.

The cut is keyframe-snapped, which is the price of not re-encoding: it starts at the last keyframe at or before startMicros and stops once the first selected stream passes endMicros. Output timestamps are rebased to start at zero.

Bitstream filters are not applied yet, so container pairs that need one (h264-in-mp4 to MPEG-TS Annex B) fail with a muxer error rather than producing a broken file.

Parameters

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros)

endMicros

trim end, on the same content-relative scale

metadata

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

onProgress

invoked every ~100 packets with the running packet count

actual suspend fun remux(input: String, output: String, streamIndices: List<Int>?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, onProgress: (packetsWritten: Long) -> Unit?)

Copy streamIndices (default: every stream the demuxer understands) from input into a fresh container at output. Format inferred from the output extension.

The cut is keyframe-snapped, which is the price of not re-encoding: it starts at the last keyframe at or before startMicros and stops once the first selected stream passes endMicros. Output timestamps are rebased to start at zero.

Bitstream filters are not applied yet, so container pairs that need one (h264-in-mp4 to MPEG-TS Annex B) fail with a muxer error rather than producing a broken file.

Parameters

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros)

endMicros

trim end, on the same content-relative scale

metadata

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

onProgress

invoked every ~100 packets with the running packet count

actual suspend fun remux(input: String, output: String, streamIndices: List<Int>?, startMicros: Long, endMicros: Long, metadata: Map<String, String>, onProgress: (packetsWritten: Long) -> Unit?)

Copy streamIndices (default: every stream the demuxer understands) from input into a fresh container at output. Format inferred from the output extension.

The cut is keyframe-snapped, which is the price of not re-encoding: it starts at the last keyframe at or before startMicros and stops once the first selected stream passes endMicros. Output timestamps are rebased to start at zero.

Bitstream filters are not applied yet, so container pairs that need one (h264-in-mp4 to MPEG-TS Annex B) fail with a muxer error rather than producing a broken file.

Parameters

startMicros

trim start, relative to the start of the content (see MediaSource.startTimeMicros)

endMicros

trim end, on the same content-relative scale

metadata

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

onProgress

invoked every ~100 packets with the running packet count