[Libav-user] regarding libavcodec method - av_parser_parse2 usage
alexcohn at netvision.net.il
Mon Mar 5 14:40:57 CET 2012
On Fri, Mar 2, 2012 at 13:32, Shiju Sasi <sasishiju at gmail.com> wrote:
> I have a multi threaded video application using x264 and ffmpeg. In the
> decoding flow, I have a question on av_parser_parse2.
> I use it as below.
> int len = 0;
> len =
> Here I get the return value len = in_buf_size. But the avpkt.data is not
> getting filled in. It gets zero, so is the avpkt.size
> To check if the error is due to the usage of AVPacket, I changed it to
> uint8_t* pOutBuf = new uint8_t;
> int iOutSize = 100;
> len =
> Here, av_parser_parse2 changed the '5' returned to all the pOutBuf locations
> to zero and the output size varable also got set as 0. I tried a uint8_t
> pointer without any memory allocated as well.
> Nothing gives me a valid output pointer, but in all cases, the parsing
> happens for the entire input variable ( as indicated by the return value of
> the function).
> Could any of you please give me more information on this?
> Thanks in advance,
The function returns the the number of bytes of the input bitstream
used. It's fine that for some while you will not receive valid packets
out of it. I don't know what kind of input stream you are using, but
it could contain quite a lot of header bytes that are necessary for
the codec context to be able to process the stream. In avcodec.h file
itself you can see an example of usage, which involves a loop:
len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
pts, dts, pos);
in_data += len;
in_len -= len;
It is normal to skip decode_frame() sometimes, when size is 0.
More information about the Libav-user