[英]create buffer source in ffmpeg
我正在嘗試為視頻創建一個 AVFilter 緩沖區。
我的源代碼是
AVFilterContext *buffersrc_ctx= nullptr;
AVFilterContext *buffersink_ctx = nullptr;
const AVFilter *buffersrc = avfilter_get_by_name("buffer");
const AVFilter *buffersink = avfilter_get_by_name("buffersink");
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
data->graph = avfilter_graph_alloc();
snprintf(args, sizeof(args),
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
data->codec_ctx->width, data->codec_ctx->height, data->codec_ctx->pix_fmt,
data->codec_ctx->time_base.num, data->codec_ctx->time_base.den,
data->codec_ctx->sample_aspect_ratio.num, data->codec_ctx->sample_aspect_ratio.den);
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
args, NULL, filter_graph);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
goto end;
}
我收到以下錯誤
[in @ 0x1cdd9c0] 提供的參數無效。 無法創建緩沖區源
還取消了 avfilter_register_all(); 在源代碼的開頭。 任何想法為什么我會收到此錯誤?
我在打開視頻幀的位置添加以下代碼行。 按照此鏈接獲取解決方案。 https://www.ffmpeg.org/doxygen/2.7/filtering_video_8c-example.html
/* select the video stream */
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n");
return ret;
}
video_stream_index = ret;
dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.