changeset 5568:1cdf9bbfbc7f libavformat

Make output-example.c handle AAC audio. Patch by Martin Storsj martin martin st
author benoit
date Thu, 21 Jan 2010 17:10:13 +0000
parents 9934ca658946
children 346dce85a801
files output-example.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/output-example.c	Thu Jan 21 15:42:05 2010 +0000
+++ b/output-example.c	Thu Jan 21 17:10:13 2010 +0000
@@ -75,6 +75,11 @@
     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 @@
 
     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;