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

Art Clarke aclarke
Mon Feb 16 19:06:51 CET 2009


On Mon, Feb 16, 2009 at 12:05 AM, Reimar D?ffinger <
Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:

> On Sun, Feb 15, 2009 at 05:10:50PM -0800, Art Clarke wrote:
> > 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.
>
> Please add a comment saying this, everyone reading it will be happy to
> know which parts are in random order and which have to be in that
> orders.
>

Attached.

- 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 17362)
+++ output_example.c	(working copy)
@@ -523,15 +523,18 @@
         }
     }
 
+    /* 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);



More information about the ffmpeg-devel mailing list