【发布时间】:2020-03-14 19:58:45
【问题描述】:
尝试将任意视频读取为纯 RGB24 像素,因此使用 sws_scale() 以这种方式转换帧:
//...
AVFrame* pic_out = av_frame_alloc();
pic_out->format = AV_PIX_FMT_RGB24;
pic_out->width = 1920;
pic_out->height = 1080;
av_frame_get_buffer( pic_out, 32 );
struct SwsContext * img_convert_ctx = sws_getContext(
1920, 1080, AV_PIX_FMT_YUV420P,
1920, 1080, AV_PIX_FMT_RGB24,
SWS_BICUBIC,
NULL, NULL, NULL
);
//...
sws_scale(
img_convert_ctx,
pic_src->data, //pic_src is from avcodec_receive_frame()
pic_src->linesize,
0,
1080,
pic_out->data,
pic_out->linesize
);
一切正常,但pic_out 最终拥有与pic_src 相同的数据。
可能是什么问题?
完整的最小示例是here(假设是 RGB24 图像存在为 2.bmp 看起来实际上是 YUV-东西)
【问题讨论】: