[Ffmpeg-devel] PixelFormat error

Martin Boehme boehme
Tue Jun 21 16:41:36 CEST 2005

Chang Min Jeon wrote:
> I'm trying to encode mpeg1.
> int saveTofile()
> {
> AVCodecContext *c = NULL;
> ....
> c->get_format = PIX_FMT_YUV420P;
> ...
> }
> error message :
> error: cannot convert `PixelFormat' to `PixelFormat (*)(AVCodecContext*, 
> const PixelFormat*)' in assignment
> I can't understand that error message.

You're trying to pass an integer where a function pointer was expected. 
 From avcodec.h:

      * callback to negotiate the pixelFormat.
      * @param fmt is the list of formats which are supported by the codec,
      * its terminated by -1 as 0 is a valid format, the formats are 
ordered byquality
      * the first is allways the native one
      * @return the choosen format
      * - encoding: unused
      * - decoding: set by user, if not set then the native format will 
always be choosen
     enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum 
PixelFormat * fmt);

(Hint: Next time you get an error message like this, avcodec.h is a good 
place to look to get an idea of what might be going on.)

But, most likely, you don't want to mess with get_format anyway. 
c->pix_fmt tells you which format the codec expects (on encoding) and 
delivers (on decoding). For MPEG-1 (as for most other codecs), it's 
PIX_FMT_YUV420P. So, as you seem to be enoding, just pass a YUV420 image 
to your codec, and everything should be fine. If the images you have are 
in a different format, use img_convert.



Martin B?hme
Inst. f. Neuro- and Bioinformatics
Ratzeburger Allee 160, D-23538 Luebeck
Phone: +49 451 500 5514
Fax:   +49 451 500 5502
boehme at inb.uni-luebeck.de

More information about the ffmpeg-devel mailing list