I have a UNCOMPRESSED TIFF MOV file I'm trying to transcode into WMV. The
video filter code works perfect but the AUDIO filter code dies when it
reaches "avfilter_graph_configs". The return code is -1. Any help would be
greatly appreciated.
Code snippet (MS VC++):
---------------------------------
buffersrc = avfilter_get_by_name("abuffer");
buffersink = avfilter_get_by_name("abuffersink");
if (!buffersrc || !buffersink) {
av_log(NULL, AV_LOG_ERROR, "filtering source or sink element not
found\n");
ret = AVERROR_UNKNOWN;
goto end;
}
if (!dec_ctx->channel_layout)
dec_ctx->channel_layout =
av_get_default_channel_layout(dec_ctx->channels);
sprintf_s(args, sizeof(args),
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%u",
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);
//time_base=1/44100:sample_rate=44100:sample_fmt=s16:channel_layout=0x3
If(avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",args, NULL,
filter_graph)<0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
goto end;
}
If(avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",NULL,
NULL, filter_graph)<0){
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
goto end;
}
If(av_opt_set_bin(buffersink_ctx,
"sample_fmts",(uint8_t*)&enc_ctx->sample_fmt,
sizeof(enc_ctx->sample_fmt),AV_OPT_SEARCH_CHILDREN)<0){
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
goto end;
}
If(av_opt_set_bin(buffersink_ctx,
"channel_layouts",(uint8_t*)&enc_ctx->channel_layout,sizeof(enc_ctx->channel
_layout), AV_OPT_SEARCH_CHILDREN<0) {
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
goto end;
}
If(av_opt_set_bin(buffersink_ctx,
"sample_rates",(uint8_t*)&enc_ctx->sample_rate,
sizeof(enc_ctx->sample_rate),AV_OPT_SEARCH_CHILDREN)<0){
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
goto end;
}
/* Endpoints for the filter graph. */
outputs->name = av_strdup("in");
outputs->filter_ctx = buffersrc_ctx;
outputs->pad_idx = 0;
outputs->next = NULL;
inputs->name = av_strdup("out");
inputs->filter_ctx = buffersink_ctx;
inputs->pad_idx = 0;
inputs->next = NULL;
if (!outputs->name || !inputs->name) {
ret = AVERROR(ENOMEM);
goto end;
}
if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_spec,&inputs,
&outputs, NULL)) < 0)
goto end;
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) //****** RETURN
-1 HERE ********
goto end;
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel