我正在尝试解码来自摄像头的H264原始协议,但是使用Jcodec H264Decoder时遇到了一些问题。我收到了一个整数数组,其中包含来自摄像头的信息。以下是数据的示例:
数组:00 00 01 FD 00 00 14 69 00 00 00 01 61 E4 80 6F D3 5B 76 97 DF 04 3A EF 54 97 0E D9 F5……更多
我正在使用的代码是:
当我尝试运行它时,我会得到如下的NullPointerException:
“Thread-6”线程中的异常java.lang.NullPointerException at org.jcodec.codecs.h264.H264Decoder $ FrameDecoder.decodeFrame(H264Decoder.java:82)at org.jcodec.codecs.h264.H264Decoder.decodeFrame(H264Decoder.java:61)at br.com.grupogiga.security.xm.player.jcodec.JCodecPlayer.test_readNals(JCodecPlayer.java:122)at br.com.grupogiga.security.xm.player.jcodec.JCodecPlayer.processNAL(JCodecPlayer.java:69)at br.com.grupogiga.security.xm.player.XMH264Player $ 1 $ 2.NALArrived(XMH264Player.java:143)at br.com.grupogiga.security.xm.protocols.ProtocolParser.emitNALArrived(ProtocolParser.java:408)at br.com.grupogiga.security.xm.protocols.ProtocolParser.run(ProtocolParser.java:121)at java.lang.Thread.run(Thread.java:722)
我做错了什么?我如何使用JCodec解码数据? 提前致谢。
数组:00 00 01 FD 00 00 14 69 00 00 00 01 61 E4 80 6F D3 5B 76 97 DF 04 3A EF 54 97 0E D9 F5……更多
我正在使用的代码是:
ByteBuffer bb = ByteBuffer.wrap( Utils.intArrayToByteArray(array, arraySize) );
bb.rewind();
// Create a buffer to hold the output picture which is big enough
Picture outBuffer = Picture.create( 1920, 1088, ColorSpace.YUV420 );
Picture pic = _decoder.decodeFrame( bb, outBuffer.getData() );
BufferedImage bufferedImage = JCodecUtil.toBufferedImage( pic );
当我尝试运行它时,我会得到如下的NullPointerException:
“Thread-6”线程中的异常java.lang.NullPointerException at org.jcodec.codecs.h264.H264Decoder $ FrameDecoder.decodeFrame(H264Decoder.java:82)at org.jcodec.codecs.h264.H264Decoder.decodeFrame(H264Decoder.java:61)at br.com.grupogiga.security.xm.player.jcodec.JCodecPlayer.test_readNals(JCodecPlayer.java:122)at br.com.grupogiga.security.xm.player.jcodec.JCodecPlayer.processNAL(JCodecPlayer.java:69)at br.com.grupogiga.security.xm.player.XMH264Player $ 1 $ 2.NALArrived(XMH264Player.java:143)at br.com.grupogiga.security.xm.protocols.ProtocolParser.emitNALArrived(ProtocolParser.java:408)at br.com.grupogiga.security.xm.protocols.ProtocolParser.run(ProtocolParser.java:121)at java.lang.Thread.run(Thread.java:722)
我做错了什么?我如何使用JCodec解码数据? 提前致谢。