执行到avfilter_graph_parse_ptr 报错 读写受保护内存
有谁能帮忙看看么?
我词穷了所有敬语称为全不让用,只能用“谁”了~哭死~~
public DrawText(AVStream* VideoStream, AVCodecContext* _pCodecContext, Size _destinationSize)
{
AVFilterGraph* filterGraph = ffmpeg.avfilter_graph_alloc();
string args = $"video_size={_destinationSize.Width}x{_destinationSize.Height}:pix_fmt={(int)AVPixelFormat.AV_PIX_FMT_RGB24
}:time_base={VideoStream->time_base.num}/{VideoStream->time_base.den}:pixel_aspect={_pCodecContext->sample_aspect_ratio.num}/{_pCodecContext->sample_aspect_ratio.den}";
AVFilterContext* srcFilterCtx;
AVFilter* srcFilter = ffmpeg.avfilter_get_by_name("buffer");
if ((ret = ffmpeg.avfilter_graph_create_filter(&srcFilterCtx, srcFilter, "out_buffer", args, null, filterGraph)) < 0)
{
LogManage.WriteLineNewInfo($"[Error creating buffer source]:[{FFmpegHelper.av_strerror(ret)}]", true);
return;
}
AVFilterContext* sinkFilterCtx;
AVFilter* sinkFilter = ffmpeg.avfilter_get_by_name("buffersink");
if ((ret = ffmpeg.avfilter_graph_create_filter(&sinkFilterCtx, sinkFilter, "in_buffersink", string.Empty, null, filterGraph)) < 0)
{
LogManage.WriteLineNewInfo($"[Error creating buffer sink]:[{FFmpegHelper.av_strerror(ret)}]", true);
return;
}
AVFilterInOut* inputs = ffmpeg.avfilter_inout_alloc();
inputs->name = ffmpeg.av_strdup("out");
inputs->filter_ctx = srcFilterCtx;
inputs->pad_idx = 0;
//outputs->next = null;
AVFilterInOut* outputs = ffmpeg.avfilter_inout_alloc();
outputs->name = ffmpeg.av_strdup("in");
outputs->filter_ctx = sinkFilterCtx;
outputs->pad_idx = 0;
//inputs->next = null;
//运行到 avfilter_graph_parse_ptr 处报错 内存越界
if ((ret = ffmpeg.avfilter_graph_parse_ptr(filterGraph, "drawtext=text='%{pts\\:hms}':x=1:y=1:fontsize=12:fontcolor=white:bordercolor=black:borderw=1", &inputs, &outputs, null)) < 0)
{
LogManage.WriteLineNewInfo($"[Could not parse filter graph]:[{FFmpegHelper.av_strerror(ret)}]", true);
return;
}