[FFmpeg-cvslog] doc/examples/muxing: pick a supported channel layout if stereo isnt supported by the encoder
Michael Niedermayer
git at videolan.org
Sat Jul 26 23:05:12 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jul 26 22:00:07 2014 +0200| [ead22f42f4fc078bb60549238233d5862da5a488] | committer: Michael Niedermayer
doc/examples/muxing: pick a supported channel layout if stereo isnt supported by the encoder
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ead22f42f4fc078bb60549238233d5862da5a488
---
doc/examples/muxing.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index b979b6d..76169a4 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -93,6 +93,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
enum AVCodecID codec_id)
{
AVCodecContext *c;
+ int i;
/* find the encoder */
*codec = avcodec_find_encoder(codec_id);
@@ -116,8 +117,15 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
c->bit_rate = 64000;
c->sample_rate = 44100;
- c->channels = 2;
c->channel_layout = AV_CH_LAYOUT_STEREO;
+ if ((*codec)->channel_layouts) {
+ c->channel_layout = (*codec)->channel_layouts[0];
+ for (i = 0; (*codec)->channel_layouts[i]; i++) {
+ if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
+ c->channel_layout = AV_CH_LAYOUT_STEREO;
+ }
+ }
+ c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
ost->st->time_base = (AVRational){ 1, c->sample_rate };
break;
More information about the ffmpeg-cvslog
mailing list