我用
Android MediaCodec库来转码视频文件(主要是改变分辨率
Sample code here)
我想要实现的另一件事是截断视频 – 仅开始15秒.逻辑是检查videoExtractor.getSampleTime()是否大于15秒,我只是将EOS写入解码器缓冲区.
但我得到一个异常引起:android.media.MediaCodec $CodecException:Error 0xfffffff3
这是我的代码:
while ((!videoEncoderDone) || (!audioEncoderDone)) { while (!videoExtractorDone && (encoderOutputVideoFormat == null || muxing)) { int decoderInputBufferIndex = videoDecoder.dequeueInputBuffer(TIMEOUT_USEC); if (decoderInputBufferIndex == MediaCodec.INFO_TRY_AGAIN_LATER) break; ByteBuffer decoderInputBuffer = videoDecoderInputBuffers[decoderInputBufferIndex]; int size = videoExtractor.readSampleData(decoderInputBuffer,0); long presentationTime = videoExtractor.getSampleTime(); if (size >= 0) { videoDecoder.queueInputBuffer( decoderInputBufferIndex,size,presentationTime,videoExtractor.getSampleFlags()); } videoExtractorDone = !videoExtractor.advance(); if (!videoExtractorDone && videoExtractor.getSampleTime() > mVideoDurationLimit * 1000000) { videoExtractorDone = true; } if (videoExtractorDone) videoDecoder.queueInputBuffer(decoderInputBufferIndex,MediaCodec.BUFFER_FLAG_END_OF_STREAM); break; }