【发布时间】:2014-09-03 03:54:17
【问题描述】:
我使用 Android 的 MediaCodec API 创建了一个编码器,代码如下:
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() 将输入传递给编码器。问题是我希望在后续调用dequeueOutputBuffer() 时使用 RGB 颜色格式帧,但由于我已将颜色格式设置为MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface,所以我认为我没有得到 RGB 帧。我需要将这些帧传递给 OpenCv 进行图像处理。
有没有办法从dequeueOutputBuffer() 获取 RGB 帧?
注意:由于不支持RGB,所以在配置编码器时无法设置RGB作为颜色格式。
【问题讨论】:
标签: android opencv colors video-processing android-mediacodec