FFMPEG 库添加 plane/frame 处理的填充
FFMPEG library add padding the plane/frame processed
我正在尝试创建一个滤镜作为 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
我正在尝试创建一个滤镜作为 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