4

I need to access each pixel informations of an AVFrame object of FFMPEG ( If it's in RGB then each color, R and G and B of each Pixel )

How can I achieve that?

EBAG
  • 21,625
  • 14
  • 59
  • 93

1 Answers1

2

If you have already advanced to the correct frame - something like:

img_convert_ctx = ffmpeg::sws_getCachedContext(img_convert_ctx,w, h, pCodecCtx->pix_fmt, w, h, ffmpeg::PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);

 ffmpeg::sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);

 //Data is in pFrameRGB->data
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • 1
    Getting the r, g and b values from pFrameRGB->data is the tough part. I've been thru a lot of code and examples but am still unable to figure it out. Could you edit your post to show how to iterate through pFrameRGB->data and to print the r, g and b values using a printf? It'd help not only me but a lot of other people who have to break their head on figuring this out. – Nav Nov 20 '12 at 15:09
  • 1
    I would also find this information helpful as figuring out libav programming is not an easy task. – KG6ZVP Nov 04 '13 at 18:51