<div dir="ltr"><div><div><div><div>Hi guys,<br><br>There was this thread about decoding NALUs one-by-one with parser2/decode2 and I'm having exactly the same issue.<br><br></div>I have x264 creating a bunch of NALUs, in annex_b and repeate_headers, and trying to decode them one by one on the client side. When I concatenate all the NALUs per frame into one large packet, and feed that directly into avcodec_decode_video2, everything is fine, the decode is successful.<br>
</div>However, when I try to feed single NALs directly to avcodec_decode_video2, it spits out a bunch of errors. After searching for a while on the net, I read some place that certain types of NALs affect the rest of the data stream, and they need to be group together. <br>
</div>I've tried to run the NALs through av_parser_parse2 and tried to decode the output buffer when the output size was larger than zero, however, after looking at the output buffer contents, it seems like while the output size seems reasonable (around the size of the NALs or a combination of a number of previous NALs), the output buffer content contains 3-4 bytes, and the rest is zero.<br>
<br></div><div>The decoding looks like this:<br><br> ret = av_parser_parse2(decoder->pParserCtx, decoder->pCodecCtx, decoder->tmp_data, &outsize, buff, size, 0, 0, AV_NOPTS_VALUE);<br> printf("%p buff, %p outdata, consumed %d, %d bufsize, %d outsize\n", buff, decoder->tmp_data,ret, size, outsize);<br>
disp_buff(decoder->tmp_data, 50);<br> <br> if (outsize <= 0) return 0;<br><br> decoder->avpkt.flags = AV_PKT_FLAG_KEY;<br> decoder->avpkt.data = decoder->tmp_data;<br> decoder->avpkt.size = outsize;<br>
<br> got_picture = 0;<br> if ((ret = avcodec_decode_video2(decoder->pCodecCtx, decoder->pFrame, &got_picture, &decoder->avpkt)) < 0) {<br> LOGE(__FUNCTION__, "H264 decoding failed!\n");<br>
return -1;<br> }<br><br><br></div><div>Could someone shed some light on if I'm really off the right track? or am I just missing something very trivial?<br><br><br></div><div>Best Regards,<br><br></div>
<div>Attila<br></div></div>