[FFmpeg-user] avformat_free_context function is not able to free the stuff that was cached by avcodec_encode_video2
Harald Jordan
harald.jordan at redstream.at
Sun Dec 23 17:16:44 CET 2012
Subject: avformat_free_context function is not able to free the stuff that
was cached by avcodec_encode_video2
Hey there!
I am not sure if this should to to the ffmpeg or libavcodec dev mailing
lists, but here is what I learned today:
avcodec_encode_video2 has the ability to cache stuff on its own if neede
(e.g GOP Encoding). Now from my dll application I learned that:
-) avcodec_encode_video2 seems to cache raw (the input buffer) instead of
only the encoded packet->data (I expected else), this can be seen by
checking the growth of memory before and after this function call
-) avformat_free_context(AVFormatContext outputcontext) did not free the
memory that the avcodec_encode_video2 function allocated all over
The solution was to close and free the outputstream on my own, using below
close_video function.
No, I already checked the void avformat_free_context(AVFormatContext *s)
function, as I see it should be able to free everything just my function
does.
Now here is the question: Was my expection right that avformat_free_context
should clean all the memory that was chached internally from
avcodec_encode_video2 ?
Merry Christmas to all of you!
Harry
static void close_video(AVFormatContext *oc, AVStream *st)
{
//free libavcodec resources
avcodec_close(st->codec);
av_free(st); //this was the final solution for the problem of getting
rid of all the stuff that was allocated internally by avcodec_encode_video2
//free our own buffers
if(picture){
av_free(picture->data[0]);
av_free(picture);
}
if (tmp_picture) {
//av_free(tmp_picture->data[0]);
av_free(tmp_picture);
}
av_free(video_outbuf);
}
More information about the ffmpeg-user
mailing list