Hello,

I've been looking at the examples on how to use ffmpeg
and I found a few issues.

Fist of all there seems to be a memory leak in
doc/examples/demuxing.c (valgrind certainly tells me that).
Freeing the AVPacket seems to resolve that issue (see the patch
attached). Hope I didn't miss anything here.

Another thing I noticed is that the demuxer example does not call
avcodec_get_frame_defaults() on the frame that it is reusing. Or
does that not really matter? The docs state that you "should"
and not "must".

Then when looking at doc/examples/decoding_encoding.c I noticed
that there is no extra call to avcodec_decode_audio4() when
decoding audio. The docs state that some decoders cache frames.
Is that really true for audio decoding? Line 601 says something about
P and I frames being delayed in the MPEG video decoder...
If so, then I think that some of the audio could go missing in this
example.

Angelo
>From 4c501007567af2e812f0a5e421354bfe5e61b07e Mon Sep 17 00:00:00 2001
From: Angelo Haller <[email protected]>
Date: Mon, 14 Jan 2013 21:26:43 +0100
Subject: [PATCH] examples/demuxing: free AVPacket after usage

---
 doc/examples/demuxing.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/doc/examples/demuxing.c b/doc/examples/demuxing.c
index bee21b7..6780e07 100644
--- a/doc/examples/demuxing.c
+++ b/doc/examples/demuxing.c
@@ -292,8 +292,10 @@ int main (int argc, char **argv)
         printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
 
     /* read frames from the file */
-    while (av_read_frame(fmt_ctx, &pkt) >= 0)
+    while (av_read_frame(fmt_ctx, &pkt) >= 0) {
         decode_packet(&got_frame, 0);
+        av_free_packet(&pkt);
+    }
 
     /* flush cached frames */
     pkt.data = NULL;
-- 
1.8.0.2

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to