【发布时间】:2020-06-30 02:26:52
【问题描述】:
我正在尝试使用 Android 媒体编解码器转换 VP9 视频。当我设置 KEY_COLOR_FORMAT 的格式转换为 YUV 格式以外的格式,我收到以下错误: "[OMX.qcom.video.decoder.vp9]不支持颜色格式XXXX。"
例如,COLOR_FormatSurface 格式似乎不受支持。或者我做错了什么。 我需要手动执行 YUV 到 RGB 的转换吗?如果是,那么能够为编解码器提供 Surfacetexture 的目的是什么?
这里是示例代码:
public class VideoDecoder
{
private MediaCodec mVideoCodec = null;
private ByteBuffer[] mInputBuffers;
private ByteBuffer[] mOutputBuffers;
public VideoDecoder(int width, int height)
{
try
{
// Media settings
MediaFormat format = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_VP9,
width,
height);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
// COLOR_FormatYUV420Flexible
// Configure the decoder
mVideoCodec = MediaCodec.createDecoderByType(MediaFormat.MIMETYPE_VIDEO_VP9);
mVideoCodec.configure(format,
null,
null,
0);
// Start the decoder
mVideoCodec.start();
mInputBuffers = mVideoCodec.getInputBuffers();
mOutputBuffers = mVideoCodec.getOutputBuffers();
}
catch(Exception e)
{
Log.e("VideoDecoder", "CreateCodec failed message =" + e.getMessage());
}
}
public void release()
{
mVideoCodec.stop();
mVideoCodec.release();
}
public void decode(byte[] rawBuffer, int frameSize)
{
//todo
}
}
谢谢!
【问题讨论】:
标签: android android-mediacodec yuv