Hello everyone,

I've read the ffmpeg tutorial and I'm trying to figure out how to access to
a precise pixel instead of a line of data. I would like to store all the
pixels in something like a memory buffer and then binarize and save my
frame to the ppm file. The frame is already converted to an RGB format as
you can see here;
https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial01.c.
Can someone help me out (I'm pretty new to ffmpeg) ?

This is the function we need to modify.

void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
  FILE *pFile;
  char szFilename[32];
  int  y;

  // Open file
  sprintf(szFilename, "frame%d.ppm", iFrame);
  pFile=fopen(szFilename, "wb");
  if(pFile==NULL)
    return;

  // Write header
  fprintf(pFile, "P6\n%d %d\n255\n", width, height);

  // Write pixel data
  for(y=0; y<height; y++)
    fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);

  // Close file
  fclose(pFile);
}
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to