[FFmpeg-cvslog] examples/decoding_encoding: flush audio frames in the encoder

Stefano Sabatini git at videolan.org
Wed Aug 22 11:56:38 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Aug 21 22:28:55 2012 +0200| [a7219529d1b872f6a8e36788de44aa3ab0a7b05e] | committer: Stefano Sabatini

examples/decoding_encoding: flush audio frames in the encoder

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a7219529d1b872f6a8e36788de44aa3ab0a7b05e
---

 doc/examples/decoding_encoding.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index d41f1fd..96b1a4b 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -205,6 +205,20 @@ static void audio_encode_example(const char *filename)
             av_free_packet(&pkt);
         }
     }
+
+    /* get the delayed frames */
+    for (got_output = 1; got_output; i++) {
+        ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
+        if (ret < 0) {
+            fprintf(stderr, "error encoding frame\n");
+            exit(1);
+        }
+
+        if (got_output) {
+            fwrite(pkt.data, 1, pkt.size, f);
+            av_free_packet(&pkt);
+        }
+    }
     fclose(f);
 
     av_freep(&samples);



More information about the ffmpeg-cvslog mailing list