From d158cd64029b216f77677bc001d97a0e1a891544 Mon Sep 17 00:00:00 2001 From: okamoto Date: Mon, 12 Aug 2024 04:24:32 +0900 Subject: [PATCH] Fix Failed to stop the muxer (#159) --- .../transcoder/internal/data/Writer.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/src/main/java/com/otaliastudios/transcoder/internal/data/Writer.kt b/lib/src/main/java/com/otaliastudios/transcoder/internal/data/Writer.kt index 1d8fc899..12aa1c2f 100644 --- a/lib/src/main/java/com/otaliastudios/transcoder/internal/data/Writer.kt +++ b/lib/src/main/java/com/otaliastudios/transcoder/internal/data/Writer.kt @@ -39,14 +39,16 @@ internal class Writer( override fun step(state: State.Ok, fresh: Boolean): State { val (buffer, timestamp, flags) = state.value val eos = state is State.Eos - info.set( - buffer.position(), - buffer.remaining(), - timestamp, - if (eos) { - flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM - } else flags - ) + if (eos) { + info.set(0, 0, 0, flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM) + } else { + info.set( + buffer.position(), + buffer.remaining(), + timestamp, + flags + ) + } sink.writeTrack(track, buffer, info) state.value.release() return if (eos) State.Eos(Unit) else State.Ok(Unit)