[英]Get YUV420 bytes from JCodec Picture
我想使用H264Decoder获得解码的YUV420数据作为Java字节数组。 我到处搜索,没有合适的例子。
ByteBuffer buf = ByteBuffer.wrap(h264EncodedByteArray); H264Decoder decoder = new H264Decoder(); // assume that sps and pps are set on the decoder Picture out = Picture.create(320, 240, ColorSpace.YUV420); Picture real = decoder.decodeFrame(buf, out.getData());
“ h264EncodedByteArray”将是来自流或文件的h264编码字节的数组。
据我所知,解码时必须提供buf和avcC框。 在开始任何解码之前,您必须提供avcC数据。
AvcCBox avcCBox = new AvcCBox(); avcCBox.parse(buf);
创建avcC之后,您可以使用以下行获取图片。
decoder.decodeFrame(H264Utils.splitMOVPacket(buf, avcCBox), out.getData());
在上面的代码中,buf可以包含或可以不包含多个NAL元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.