Make output-example.c handle AAC audio.

Patch by Martin Storsjö martin martin st

Originally committed as revision 21367 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Martin Storsjö 2010-01-21 17:10:13 +00:00 committed by Benoit Fouet
parent 31f6e3c19e
commit 073189917e
1 changed files with 6 additions and 1 deletions

View File

@ -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;