从C ++中的AVFrame(FFMPEG)中提取RGB值

时间:2021-10-04 04:20:53

I am currently trying to read in video frames by using FFMPEG. The format is PIX_FMT_RGB24; For each frame, the RGB values are all combined together in frame->data[0] (Where frame is of the type AVFrame).

我目前正在尝试使用FFMPEG读取视频帧。格式为PIX_FMT_RGB24;对于每个帧,RGB值都在frame-> data [0]中组合在一起(其中frame是AVFrame类型)。

How do I extract the individual R, G and B values for each frame? This is for processing the video. I would think it would work the same way as extracting the RGB values from a bitmap too. Thanks!

如何为每个帧提取单独的R,G和B值?这是用于处理视频。我认为它的工作方式与从位图中提取RGB值的方式相同。谢谢!

1 个解决方案

#1


My guess:

int p=x*3+y*frame->linesize[0];
r=frame->data[0][p];
g=frame->data[0][p+1];
b=frame->data[0][p+2];

I might have r, g, and b backwards. And there's a lot of room for speedup.

我可能有r,g和b向后。而且还有很大的加速空间。

#1


My guess:

int p=x*3+y*frame->linesize[0];
r=frame->data[0][p];
g=frame->data[0][p+1];
b=frame->data[0][p+2];

I might have r, g, and b backwards. And there's a lot of room for speedup.

我可能有r,g和b向后。而且还有很大的加速空间。