[FFmpeg-cvslog] r21367 - trunk/libavformat/output-example.c

benoit subversion
Thu Jan 21 18:10:13 CET 2010


Author: benoit
Date: Thu Jan 21 18:10:13 2010
New Revision: 21367

Log:
Make output-example.c handle AAC audio.
Patch by Martin Storsj? martin martin st

Modified:
   trunk/libavformat/output-example.c

Modified: trunk/libavformat/output-example.c
==============================================================================
--- trunk/libavformat/output-example.c	Thu Jan 21 17:50:31 2010	(r21366)
+++ trunk/libavformat/output-example.c	Thu Jan 21 18:10:13 2010	(r21367)
@@ -75,6 +75,11 @@ static AVStream *add_audio_stream(AVForm
     c->bit_rate = 64000;
     c->sample_rate = 44100;
     c->channels = 2;
+
+    // some formats want stream headers to be separate
+    if(oc->oformat->flags & AVFMT_GLOBALHEADER)
+        c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+
     return st;
 }
 
@@ -156,7 +161,7 @@ static void write_audio_frame(AVFormatCo
 
     pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples);
 
-    if (c->coded_frame->pts != AV_NOPTS_VALUE)
+    if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
         pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
     pkt.flags |= PKT_FLAG_KEY;
     pkt.stream_index= st->index;



More information about the ffmpeg-cvslog mailing list