尝试将任意视频读取为纯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-某物)]
pic_out->data
视为RGB24图像数据,但必须是pic_out->data[0]