]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
av_write_trailer() must be done before closing codecs.
authorandoma <andoma@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 18 Feb 2009 06:49:32 +0000 (06:49 +0000)
committerandoma <andoma@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 18 Feb 2009 06:49:32 +0000 (06:49 +0000)
Patch by aclarke a xuggle d com

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17422 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

output_example.c

index 612146dad0d0a462a03a864c1eee9c78ab59e712..6cd1b34080bd3b22eec1c70b4cd081d328969391 100644 (file)
@@ -523,15 +523,18 @@ int main(int argc, char **argv)
         }
     }
 
+    /* write the trailer, if any.  the trailer must be written
+     * before you close the CodecContexts open when you wrote the
+     * header; otherwise write_trailer may try to use memory that
+     * was freed on av_codec_close() */
+    av_write_trailer(oc);
+
     /* close each codec */
     if (video_st)
         close_video(oc, video_st);
     if (audio_st)
         close_audio(oc, audio_st);
 
-    /* write the trailer, if any */
-    av_write_trailer(oc);
-
     /* free the streams */
     for(i = 0; i < oc->nb_streams; i++) {
         av_freep(&oc->streams[i]->codec);