'What's the difference between avfilter_graph_parse_ptr() and avfilter_link()?
I use the same set of codec to verify different methods.For audio, there is little difference between the two methods. For video, the following situation will occur. This is the way use avfilter_link(), but it can't trim video.
...
const AVFilter *trim = avfilter_get_by_name("trim");
char args[128] = { 0 };
snprintf(args, sizeof(args), "start=10:end=60");
AVFilterContext *trim_ctx;
avfilter_graph_create_filter(&trim_ctx, trim, "video_trim", args, NULL, videofilterGraph);
avfilter_link(videoBuffSrc, 0, trim_ctx, 0);
...
const AVFilter *setpts= avfilter_get_by_name("setpts");
char args[128] = { 0 };
snprintf(args, sizeof(args), "PTS-STARTPTS");
AVFilterContext *setpts_ctx;
avfilter_graph_create_filter(&setpts_ctx, setpts, "video_setpts", args, NULL, videofilterGraph);
avfilter_link(trim_ctx, 0, setpts_ctx, 0);
...
//Finally linked format and buffsink.
This is the way use avfilter_graph_parse_ptr(), it works well.
AVFilter* buffersrc = avfilter_get_by_name("buffer");
AVFilter* buffersink = avfilter_get_by_name("buffersink");
AVFilterInOut* inputs = avfilter_inout_alloc();
AVFilterInOut* outputs = avfilter_inout_alloc();
...
avfilter_graph_parse_ptr(videofilterGraph, "trim=start=10:end=60,setpts=PTS-STARTPTS", &inputs, &outputs, NULL)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
