[Libav-user] avcodec_decode_video2 freeing buffer quickly

Matthew Einhorn moiein2000 at gmail.com
Thu Mar 1 00:04:16 CET 2012


Hi,

I seem to have a bit of trouble where avcodec_decode_video2 frees the
frame it decoded too quickly. I'm wondering how long I can expect the
frame to be valid.

My code does as follows:
In one function I call call av_read_frame, avcodec_decode_video2, and
av_free_packet in series until I get a complete frame in which case
the function returns. Then, I call again from another function (same
thread etc) to copy the decoded frame into my buffer. It seems that
between these function call (in which I do nothing else with the
decoder) the frame gets freed so I get an exception. This means that I
have to buffer the decoded frame, which takes extra copying.

It also only seems to happen when the video decoded is bgr24 (vs
yuv420p). Obviously I can overwrite the default get/release_buffer()
but I'd rather not (since it has to be supported by codec). So I'm
wondering if this is normal behavior? But it's no big deal.

Thanks,
Matt


More information about the Libav-user mailing list