我正在尝试创建一个过滤器作为 FFMPEG 的一部分。在创建它的过程中,我需要在框架周围创建一个填充,这样图像就不会重新采样,只具有所需的宽度和高度。我知道这可以通过 libswscale/swscale.h 实现,但我无法找到任何有关如何为正在处理的平面进行填充的示例。示例代码如下:
if (av_frame_is_writable(in)) {
out = in;
} else {
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, in);
}
for (p = 0; p < filter->nb_planes; p++) {
// did not find any documentation as to
//how set those attributes to add padding to the plane
filter->sws_ctx = sws_getContext(src_w, src_h, src_pix_fmt,
dst_w, dst_h, dst_pix_fmt,
SWS_BILINEAR, NULL, NULL, NULL);
}
最佳答案
没有其他方法可以在过滤器内执行此操作。该功能必须通过 vf_pad
过滤器实现。
图片来源:@durandal_1707,来自 #ffmpeg IRC
关于c - FFMPEG 库添加填充处理的平面/帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43424731/