如何利用媒体codeC连接codeR得到RGB色彩格式帧 [英] How to get RGB color-format frames using MediaCodec encoder

查看:1205
本文介绍了如何利用媒体codeC连接codeR得到RGB色彩格式帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个连接codeR使用以下code。使用Android的媒体codeC API:

I've created an encoder using the Android's MediaCodec API using the following code :

MediaFormat mMediaFormat = MediaFormat.createVideoFormat("video/avc", width, height);
            mMediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);
            mMediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 15);
            mMediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT,     MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
            mMediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10);
            Log.i(TAG, "Starting encoder");
            encoder = MediaCodec.createByCodecName(Utils.selectCodec("video/avc").getName());
            encoder.configure(mMediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
            Surface surface = encoder.createInputSurface();
            encoder.start();

我用 createInputSurface()来传递输入到EN $ C $铬。问题是我想在以后调用 RGB颜色格式的帧dequeueOutputBuffer(),但因为我已经设置颜色格式媒体codecInfo。codecCapabilities.COLOR_FormatSurface 所以我觉得我没有得到RGB帧。我需要将这些帧传递给OpenCV进行图像处理。
有没有什么办法让从 RGB帧dequeueOutputBuffer()

I'm using createInputSurface() to pass the input to the encoder. The problem is I want RGB color-format frames in the subsequent calls to dequeueOutputBuffer() but since I've set the color format to MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface so I think I'm not getting RGB frames. I need to pass these frames to OpenCv for image processing. Is there any way to get RGB frames from dequeueOutputBuffer() ?

注意:因为它不支持我不能带codeR的组态期间设置为RGB颜色格式

Note : I cannot set RGB as the color format during the configuring of the encoder because it's not supported.

推荐答案

在连接codeR的输出是AVC-CN codeD帧。这不是RGB或YUV,这是AVC。

The output of the encoder is AVC-encoded frames. It's not RGB or YUV, it's AVC.

颜色格式指出你所喂养的的带连接codeR帧的格式,而不是什么来的的,所以它有没有影响什么您从获得dequeueOutputBuffer()

The color format specifies the format of the frames you're feeding into the encoder, not what comes out, so it has no effect on what you get from dequeueOutputBuffer().

如果您需要操作的原始帧,你应该将它们传递到EN codeR之前这样做。

If you need to manipulate the raw frames, you should do so before passing them into the encoder.

这篇关于如何利用媒体codeC连接codeR得到RGB色彩格式帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆