doc/examples/transcode: stop using avfilter_graph_create_filter() incorrectly

See previous commits for details.
This commit is contained in:
Anton Khirnov 2024-09-25 12:18:31 +02:00
parent 87faa8aeba
commit d18d119b8f
1 changed files with 18 additions and 6 deletions

View File

@ -283,10 +283,10 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
goto end; goto end;
} }
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out", buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, buffersink, "out");
NULL, NULL, filter_graph); if (!buffersink_ctx) {
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n"); av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
ret = AVERROR(ENOMEM);
goto end; goto end;
} }
@ -297,6 +297,12 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n"); av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
goto end; goto end;
} }
ret = avfilter_init_dict(buffersink_ctx, NULL);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot initialize buffer sink\n");
goto end;
}
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { } else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
char buf[64]; char buf[64];
buffersrc = avfilter_get_by_name("abuffer"); buffersrc = avfilter_get_by_name("abuffer");
@ -322,10 +328,10 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
goto end; goto end;
} }
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out", buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, buffersink, "out");
NULL, NULL, filter_graph); if (!buffersink_ctx) {
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n"); av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
ret = AVERROR(ENOMEM);
goto end; goto end;
} }
@ -352,6 +358,12 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n"); av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
goto end; goto end;
} }
ret = avfilter_init_dict(buffersink_ctx, NULL);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot initialize audio buffer sink\n");
goto end;
}
} else { } else {
ret = AVERROR_UNKNOWN; ret = AVERROR_UNKNOWN;
goto end; goto end;