我想使用函数 ff_load_image
。
program.c
#include "../ffmpeg/libavfilter/lavfutils.h"
int main ()
{
uint8_t* data;
int linesize, width, height, log_ctx;
int i = ff_load_image(&data, &linesize, &width, &height, AV_PIX_FMT_RGB24, "blue.jpg", &log_ctx);
}
这会编译,但会给出警告。
program.c: In function 'main':
program.c:11: warning: passing argument 5 of 'ff_load_image' makes pointer from integer without a cast
../ffmpeg/libavfilter/lavfutils.h:39: note: expected 'enum AVPixelFormat *' but argument is of type 'int'
当我运行程序时,它出现段错误。我想不出任何其他方式来指定像素格式。为什么 ffmpeg 认为 AV_PIX_FMT_RGB8
是一个整数?这显然是一个 AVPixelFormat
。
最佳答案
ff_load_image()
需要一个 enum AVPixelFormat *
。 ffmpeg
认为它是一个整数,因为它是 AVPixelFormat
的一个 enum
元素。 .而且,in C
, 枚举常量的类型为 int
。
你应该使用:
enum AVPixelFormat pix_fmt = AV_PIX_FMT_RGB24;
int i = ff_load_image(&data, &linesize, &width, &height
, &pix_fmt, "blue.jpg", &log_ctx);
关于c++ - ffmpeg:将 AVPixelFormat 视为 Int?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22433055/