Re: [GD-DEVEL] Problems converting AVFrame to gdImagePtr

[email protected] (Pierre Joye) Sat, 30 May 2009 19:39:08 +0200
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hi,

Do you use ffmpeg? There is an example in cvs:

http://cvs.php.net/viewvc.cgi/gd/playground/ffmpeg/

Cheers,

On Sat, May 30, 2009 at 4:44 PM, Udo Pokojski <[email protected]> wrote:
> Hi,
>
> I am trying to extract single frame from a MP2-File. The frames are
> extracted and saved as AVFrame. For further processing I want to convert
> the AVFrame to an gdImagePtr. The conversion should be done by this
> code:
> -------------------------------------------------------------------------
> void SaveFrame_png(AVFrame *pFrame, int width, int height, int iFrame) {
>  FILE *pFile;
>  char szFilename[32];
>  int  x,y;
>  gdImagePtr im;
>  int *src;
>
>  im=gdImageCreateTrueColor(width, height);
>    //gdImageInterlace(im, 1);
>  src = (int *) pFrame->data[0];
>  for(y=0; y < height; y++) {
>    for (x=0; x < width; x++) {
>       gdImageSetPixel(im, x, y, src[x] & 0x00FFFFFF);
>       //   im->tpixels[y][x] = src[x] & 0x00FFFFFF;
>        }
>        src += width;
>  }
>
>  sprintf(szFilename, "frame%d.png", iFrame);
>  pFile=fopen(szFilename, "wb");
>  if(pFile==NULL)
>    return;
>  gdImageInterlace(im,1);
>  gdImagePng(im,pFile);
>
>  fclose(pFile);
>
> }
>
> ------------------------------------------------------------------------------
>
> For a quick test, I save the gdImagePtr as a PNG-File.
> The resulting file shows a kind of interlace and a multiple horizontal
> shift. I have uploaded an example to
> http://www.freeimagehosting.net/uploads/081ff0fcb2.png
>
> Write a JPG-File gives the same result.
> Where is the error in this code?
>
> Thx,
> Udo
>
>
>
>
> --
> GD Devel Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org