From 073189917e4dfa0640e8180110b07e130471f37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Jan 2010 17:10:13 +0000 Subject: [PATCH] =?UTF-8?q?Make=20output-example.c=20handle=20AAC=20audio.?= =?UTF-8?q?=20Patch=20by=20Martin=20Storsj=C3=B6=20martin=20martin=20st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally committed as revision 21367 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/output-example.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/output-example.c b/libavformat/output-example.c index 17c97f79db..7eb3352b74 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -75,6 +75,11 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id) 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(AVFormatContext *oc, AVStream *st) 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;