mediaCodec = MediaCodec.createDecoderByType("video/avc");
MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/avc", 1920, 1080);
mediaCodec.configure(mediaFormat, palyer_surfaceView.getHolder().getSurface(), null, 0);
// mediaCodec = MediaCodec.createDecoderByType("audio/mp4a-latm");
// MediaFormat format = new MediaFormat();
// format.setString(MediaFormat.KEY_MIME, "audio/mp4a-latm");
// format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1);
// format.setInteger(MediaFormat.KEY_SAMPLE_RATE, 44100);
// format.setInteger(MediaFormat.KEY_BIT_RATE, 64 * 1024);//AAC-HE 64kbps
// format.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectHE);
// mediaCodec.configure(format, null, null, 0);
mediaCodec.start();
ByteBuffer[] inputBuffers = mediaCodec.getInputBuffers();
int inputBufferIndex = mediaCodec.dequeueInputBuffer(0);
if (inputBufferIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
inputBuffer.clear();
inputBuffer.put(buffer, 0, buffer.length);
mediaCodec.queueInputBuffer(inputBufferIndex, 0, buffer.length, mCount * 100000 / 30, 0);
mCount++;
}
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
int outputBufferIndex = mediaCodec.dequeueOutputBuffer(bufferInfo, 1000);
if (outputBufferIndex >= 0) {
mediaCodec.releaseOutputBuffer(outputBufferIndex, true);
}
共同学习,写下你的评论
评论加载中...
作者其他优质文章