[英]Decode H264 From Array of Integers
我正在嘗試從相機解碼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 ...更多
我正在使用的代碼是:
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如下:
Org.jcodec.codecs.h264.H264Decoder.decodeFrame(H264Decoder.java)中org.jcodec.codecs.h264.H264Decoder $ FrameDecoder.decodeFrame(H264Decoder.java:82)中的線程“Thread-6”java.lang.NullPointerException中的異常:61)位於br.com.grupogiga.security.xm.player.jcodec.JCodecPlayer.test_readNals(JCodecPlayer.java:122)的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) )在java.com.lang.Thread.run(Thread.java:722)的br.com.grupogiga.security.xm.protocols.ProtocolParser.run(ProtocolParser.java:121)
我做錯了什么? 如何使用JCodec解碼數據? 提前致謝。
你確定你得到一個int數組嗎? 它看起來像是打印輸出的字節數組。 我建議不要進行數組轉換,也不要做倒帶; ByteBuffer.wrap已經將你放在緩沖區的第0位。 00 00 01是NAL標記的開始,FD是NAL類型的btw。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.