[FFmpeg-user] avio_close() delay in releasing file on Windows/MinGW?

Thomas Worth dev at rarevision.com
Sat May 28 22:34:57 CEST 2011


Using MinGW on Windows 7, I create an output file like this:

char *output_file = "somefile.mov";

AVFormatContext *outputCtx;
avformat_alloc_output_context2(&outputCtx, NULL, NULL, output_file);
AVOutputFormat *fmt = outputCtx->oformat;

blah blah code blah...

if(!(fmt->flags & AVFMT_NOFILE)){
if(avio_open(&outputCtx->pb, output_file, AVIO_FLAG_WRITE) < 0) {
 return -1;
}
}

av_write_header(outputCtx);

blah blah more code...

avio_close(outputCtx->pb);
av_freep(outputCtx);

This all works fine. But if I try to open the file immediately after:

FILE *infile;
if(!(infile = fopen(output_file,"rb+"))){
return -1;
}

This fails 99% of the time, but once in a while it will work! What's going
on here? I am I forgetting to release something?


More information about the ffmpeg-user mailing list