9

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).

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!

Extrakun
  • 19,057
  • 21
  • 82
  • 129
  • Just a clarification - I need the R, G and B value standalone; I should already have the raw RGB data from the AvFrame – Extrakun Jun 26 '09 at 03:52

1 Answers1

5

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.

David
  • 2,164
  • 13
  • 11
  • Related answer: http://stackoverflow.com/questions/9912873/ffmpeg-avframe-get-full-decoded-data-to-char – Nav Nov 02 '12 at 11:00