diff options
author | James Almer <jamrial@gmail.com> | 2022-01-20 17:47:51 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:47 -0300 |
commit | f5ef91e02080316f50d606f5b0b03333bb627ed7 (patch) | |
tree | d6338f72a9ee59dfbf29024ae5d5a5aa29d81ce9 /doc/examples/transcoding.c | |
parent | 50e9e11316064ecdee889b18a0b6681a248edcf4 (diff) | |
download | ffmpeg-f5ef91e02080316f50d606f5b0b03333bb627ed7.tar.gz |
doc/examples: convert to new channel layout-API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'doc/examples/transcoding.c')
-rw-r--r-- | doc/examples/transcoding.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index badfba62cb..013f89fc7d 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -175,8 +175,9 @@ static int open_output_file(const char *filename) enc_ctx->time_base = av_inv_q(dec_ctx->framerate); } else { enc_ctx->sample_rate = dec_ctx->sample_rate; - enc_ctx->channel_layout = dec_ctx->channel_layout; - enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout); + ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout); + if (ret < 0) + return ret; /* take first format from list of supported formats */ enc_ctx->sample_fmt = encoder->sample_fmts[0]; enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; @@ -289,6 +290,7 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, goto end; } } else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { + char buf[64]; buffersrc = avfilter_get_by_name("abuffer"); buffersink = avfilter_get_by_name("abuffersink"); if (!buffersrc || !buffersink) { @@ -297,14 +299,14 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, goto end; } - if (!dec_ctx->channel_layout) - dec_ctx->channel_layout = - av_get_default_channel_layout(dec_ctx->channels); + if (dec_ctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) + av_channel_layout_default(&dec_ctx->ch_layout, dec_ctx->ch_layout.nb_channels); + av_channel_layout_describe(&dec_ctx->ch_layout, buf, sizeof(buf)); snprintf(args, sizeof(args), - "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64, + "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=%s", dec_ctx->time_base.num, dec_ctx->time_base.den, dec_ctx->sample_rate, av_get_sample_fmt_name(dec_ctx->sample_fmt), - dec_ctx->channel_layout); + buf); ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in", args, NULL, filter_graph); if (ret < 0) { @@ -327,9 +329,9 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx, goto end; } - ret = av_opt_set_bin(buffersink_ctx, "channel_layouts", - (uint8_t*)&enc_ctx->channel_layout, - sizeof(enc_ctx->channel_layout), AV_OPT_SEARCH_CHILDREN); + av_channel_layout_describe(&enc_ctx->ch_layout, buf, sizeof(buf)); + ret = av_opt_set(buffersink_ctx, "ch_layouts", + buf, AV_OPT_SEARCH_CHILDREN); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n"); goto end; |