[Libav-user] Correct way of freeing an AVFrame coming from avcodec_decode_video2

Info || Non-Lethal Applications info at non-lethal-applications.com
Fri Jul 4 16:09:53 CEST 2014

Hey guys, 

I’m creating a recording application and I have an incoming frame which I’d like to convert to JPEG without writing it to a movie file.
However, I need to use libav’s V210 decoder before creating the JPEG data.

I’m getting a memory leak in this code:

AVPacket pkt;
pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index  = 0;
pkt.data = imgData;
pkt.size = ...
int gotPctr = 0;
AVFrame* frameGrabFrame = av_frame_alloc();
avcodec_decode_video2(_pV210CodecCtxFrameGrab, frameGrabFrame, &gotPctr, &pkt);
I get a memory consumption increase of about 13 MB after the avcodec_decode call.
However, I can’t manage to free the memory. I already tried without success:


I’m not using reference counting by the way.
I’m sure that’s a dumb one … sorry for that.

Any advice appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140704/22ff56dd/attachment.html>

More information about the Libav-user mailing list