Get YUV420 bytes from JCodec Picture

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:43:50

问题


Using an H264Decoder I would like to obtain the decoded YUV420 data as a Java byte array. I have searched all over and I don't see any examples that fit.

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());

The "h264EncodedByteArray" would be an array of h264 encoded bytes from a stream or file.


回答1:


As far as I can tell the buf and avcC box must be supplied when doing the decode. Before any decoding can commence, you must provide avcC data.

AvcCBox avcCBox = new AvcCBox();
avcCBox.parse(buf);

After the avcC is created, you can use the following line to get the Picture.

decoder.decodeFrame(H264Utils.splitMOVPacket(buf, avcCBox), out.getData());

In the code above the buf may or may not contain multiple NAL elements.



来源:https://stackoverflow.com/questions/25272726/get-yuv420-bytes-from-jcodec-picture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!