avf: fix audio writing in the output-example
authorLuca Barbato <lu_zero@gentoo.org>
Thu, 29 Mar 2012 19:00:37 +0000 (12:00 -0700)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 30 Mar 2012 00:07:19 +0000 (17:07 -0700)
av_init_packet does not reset data and size fields in AVPacket,
avcodec_encode_audio2 can use preallocated AVPacket.

libavformat/output-example.c

index 86324b4..a467109 100644 (file)
@@ -138,7 +138,7 @@ static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)
 static void write_audio_frame(AVFormatContext *oc, AVStream *st)
 {
     AVCodecContext *c;
-    AVPacket pkt;
+    AVPacket pkt = { 0 }; // data and size must be 0;
     AVFrame *frame = avcodec_alloc_frame();
     int got_packet;