1

I'm compressing a video with audio on android using MediaCodec. When I run the code in a try/catch the output video is fine apart from the last part of the audio is missing.

I've had to rewrite the code and also convert it into Kotlin but nothing has worked so far. I've seen a few similar issues on here but the error code is slightly different as it is more of an audio issue whereas this looks like an issue with the video extraction.

Here's the code where the error is happening. The line with videoDecoder.queueInputBuffer is exactly the crash.

videoExtractorDone = !videoExtractor.advance()
    if (videoExtractorDone) {
        if (false) Log.d(TAG, "video extractor: EOS")
            videoDecoder.queueInputBuffer(decoderInputBufferIndex, 0, 0, 0, videoDecoderOutputBufferInfo.flags)
    }

How can I solve this issue so that the clip has full audio? I can't lose any of the audio from this process.

AngryCubeDev
  • 155
  • 2
  • 16
  • have you found anything about this issue? – snachmsm Sep 24 '19 at 11:59
  • @snachmsm I ended up just rewriting most the media codec library for our project and it was solved as part of that. I can't think off the top of my head what caused it but if I do I'll update the page. – AngryCubeDev Sep 25 '19 at 08:24
  • my app is throwing this exception after api update (`targetSdkVersion 29`) in line `queueInputBuffer(decoderInputBufferIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM)`. base code [HERE](https://stackoverflow.com/questions/29943121/mediamuxer-video-file-size-reducing-re-compress-decrease-resolution/29975404). maybe you can share some code or maybe just a part with ending/closing whole muxing process? – snachmsm Sep 25 '19 at 08:48

0 Answers0