Mercurial > libavformat.hg
comparison output-example.c @ 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 | cb7a82c74dcc |
| children | 21c98b55a800 |
comparison
equal
deleted
inserted
replaced
| 5567:9934ca658946 | 5568:1cdf9bbfbc7f |
|---|---|
| 73 | 73 |
| 74 /* put sample parameters */ | 74 /* put sample parameters */ |
| 75 c->bit_rate = 64000; | 75 c->bit_rate = 64000; |
| 76 c->sample_rate = 44100; | 76 c->sample_rate = 44100; |
| 77 c->channels = 2; | 77 c->channels = 2; |
| 78 | |
| 79 // some formats want stream headers to be separate | |
| 80 if(oc->oformat->flags & AVFMT_GLOBALHEADER) | |
| 81 c->flags |= CODEC_FLAG_GLOBAL_HEADER; | |
| 82 | |
| 78 return st; | 83 return st; |
| 79 } | 84 } |
| 80 | 85 |
| 81 static void open_audio(AVFormatContext *oc, AVStream *st) | 86 static void open_audio(AVFormatContext *oc, AVStream *st) |
| 82 { | 87 { |
| 154 | 159 |
| 155 get_audio_frame(samples, audio_input_frame_size, c->channels); | 160 get_audio_frame(samples, audio_input_frame_size, c->channels); |
| 156 | 161 |
| 157 pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples); | 162 pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples); |
| 158 | 163 |
| 159 if (c->coded_frame->pts != AV_NOPTS_VALUE) | 164 if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) |
| 160 pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base); | 165 pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base); |
| 161 pkt.flags |= PKT_FLAG_KEY; | 166 pkt.flags |= PKT_FLAG_KEY; |
| 162 pkt.stream_index= st->index; | 167 pkt.stream_index= st->index; |
| 163 pkt.data= audio_outbuf; | 168 pkt.data= audio_outbuf; |
| 164 | 169 |
