[FFmpeg-devel] [PATCH] Fix output_example.c to call av_write_trailer before closing codecs

Art Clarke aclarke
Mon Feb 16 02:10:50 CET 2009


Otherwise for containers that want global headers (e.g. mov),
av_write_trailer will try to access memory in the video codec that has been
freed on the av_codec_close.

- Art

-- 
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and
video.

Use Xuggle to get the power of FFMPEG in Java.
-------------- next part --------------
Index: output_example.c
===================================================================
--- output_example.c	(revision 17348)
+++ output_example.c	(working copy)
@@ -523,15 +523,15 @@
         }
     }
 
+    /* write the trailer, if any */
+    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);



More information about the ffmpeg-devel mailing list