从JCodec图片获取YUV420字节

编程入门 行业动态 更新时间:2024-10-22 08:33:00
本文介绍了从JCodec图片获取YUV420字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用H264Decoder,我想将已解码的YUV420数据作为Java字节数组获取.我搜索了所有内容,但没有找到合适的示例.

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

"h264EncodedByteArray"将是来自流或文件的h264编码字节的数组.

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

推荐答案

据我所知,解码时必须提供buf和avcC框.在开始任何解码之前,您必须提供avcC数据.

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

创建avcC之后,您可以使用以下行获取图片.

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

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

在上面的代码中,buf可能包含或可能不包含多个NAL元素.

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

更多推荐

从JCodec图片获取YUV420字节

本文发布于:2023-11-30 20:40:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字节   图片   JCodec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!