我使用ffmpeg在C++中提取视频帧。我想在C++中获得框架的array<unsigned char>
,但是我从此行代码中获得AVFrame
。将AVPicture转换为数组<unsigned char>
avcodec_decode_video2(codecContext, DecodedFrame, &gotPicture, Packet);
所以我用sws_scale
转换AVFrame
到AVPicture
而且我不能接到框架array<unsigned char>
。
sws_scale(convertContext, DecodedFrame->data, DecodedFrame->linesize, 0, (codecContext)->height, convertedFrame->data, convertedFrame->linesize);
因此,谁能帮我AVFrame
或AVPicture
到array<unsigned char>
转换?
解码的帧通常是YUV,并且图像以平面形式存储在AVFrame.data [0-2]中。对于使用swscale后的RGB转换,这将会有所不同,但仍然是AVFrame.data []中的像素数据。 AVFrame.linesize []通常与宽度不同,所以请记住。 – WLGfx