“MediaCodec 解码器可以使用上述格式之一或专有格式在 ByteBuffers 中生成数据。例如,基于 Qualcomm SoC 的设备通常使用 OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m (#2141391876 / 0x7FA30C04)。”
这使得处理输出缓冲区变得困难甚至无法处理。为什么不使用统一的YUV格式?为什么有这么多YUV颜色格式?
@fadden,我发现可以解码到 Surface 并获取 RGB 缓冲区(如http://bigflake.com/mediacodec/ExtractMpegFramesTest.java.txt),我可以将 RGB 缓冲区传输为 YUV 格式然后对其进行编码吗?
而且,fadden,我尝试使用 API 18+ 并遇到了一些问题。我参考了 ContinuousCaptureActivity 和 ExtractMpegFramesTest 代码。在ContinuousCaptureActivity中:
mEglCore = new EglCore(null, EglCore.FLAG_RECORDABLE);
mDisplaySurface = new WindowSurface(mEglCore, holder.getSurface(), false);
mDisplaySurface.makeCurrent();
mFullFrameBlit = new FullFrameRect(
new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
mTextureId = mFullFrameBlit.createTextureObject();
mCameraTexture = new SurfaceTexture(mTextureId);
mCameraTexture.setOnFrameAvailableListener(this);
mCamera.setPreviewTexture(mCameraTexture);
Run Code Online (Sandbox Code Playgroud)
FullFrameRect 创建一个 SurfaceTexture 并将其设置为相机预览纹理。
但是在 ExtractMpegFramesTest 中,使用了 CodecOutputSurface 并且它还创建了一个纹理。我怎样才能一起使用 CodecOutputSurface 和 FullFrameRect?(一个提供表面来接收解码器输出,一个重新缩放并渲染到编码器输入表面。)