[Libav-user] Newbie: H264 codec context parameters

Chu Xuan Khoi khoicx at tsdv.com.vn
Thu Dec 29 04:35:47 CET 2011

Dear all,
It is the first time I write H264 decoder by using libavcodec. I have some
trouble when create the codec context: I created a new codec context and
assigned the parameters:
codecDecode = avcodec_find_decoder(CODEC_ID_H264);
if (!codecDecode) {
  fprintf(stderr, "codec not found\n");
ctxDecode= avcodec_alloc_context();
ctxDecode->flags2 |= CODEC_FLAG2_FAST;
ctxDecode->pix_fmt = PIX_FMT_YUV420P;
ctxDecode->width = clip_width;
ctxDecode->height = clip_height;
ctxDecode->dsp_mask = (FF_MM_MMX | FF_MM_MMXEXT | FF_MM_SSE);

if (avcodec_open(ctxDecode, codecDecode) < 0) {
  fprintf(stderr, "could not open codec\n");
It cannot decode the packets.
I have tried to change the file mpeg2 video with CODEC_ID_MPEG2VIDEO. The code
What is my problem? Do any more parameters need to be assigned in decode

More information about the Libav-user mailing list