title: AVCodecContext settings for H264 (1080i)
body: <p>I'm trying to configure x264 for 1080i capturing. Most of these settings below are found in different examples. However, compiled together they don't work. ffmpeg API reports no error, but <code>avcodec_encode_video()</code> always returns zero.</p>
  
  <p>Some of the numbers are strange to me... for example, <code>gop_size</code>. Isn't 250 too high?</p>
  
  <p>Event you can't offer the final answer, I'm still interested in any kind of comment on this subject. </p>
  
  <pre><code>pCodecContext-&gt;codec_type              = AVMEDIA_TYPE_VIDEO;
  pCodecContext-&gt;codec_id                = CODEC_ID_H264;
  
  pCodecContext-&gt;coder_type              = FF_CODER_TYPE_AC;
  pCodecContext-&gt;flags                  |= CODEC_FLAG_LOOP_FILTER | CODEC_FLAG_INTERLACED_ME | CODEC_FLAG_INTERLACED_DCT;
  pCodecContext-&gt;me_cmp                 |= 1;
  pCodecContext-&gt;partitions             |= X264_PART_I8X8 | X264_PART_I4X4 | X264_PART_P8X8 | X264_PART_B8X8;
  pCodecContext-&gt;me_method               = ME_UMH;
  pCodecContext-&gt;me_subpel_quality       = 8;
  pCodecContext-&gt;me_range                = 16;
  
  pCodecContext-&gt;bit_rate                = 10 * 1024 * 1024; // 10 Mbps??
  pCodecContext-&gt;width                   = 1920;
  pCodecContext-&gt;height                  = 1080;
  
  pCodecContext-&gt;time_base.num           = 1;    // 25 fps
  pCodecContext-&gt;time_base.den           = 25;   // 25 fps
  
  pCodecContext-&gt;gop_size                = 250; // 250
  pCodecContext-&gt;keyint_min              = 25;
  pCodecContext-&gt;scenechange_threshold   = 40;
  pCodecContext-&gt;i_quant_factor          = 0.71f;
  pCodecContext-&gt;b_frame_strategy        = 1;
  pCodecContext-&gt;qcompress               = 0.6f;
  pCodecContext-&gt;qmin                    = 10;
  pCodecContext-&gt;qmax                    = 51;
  pCodecContext-&gt;max_qdiff               = 4;
  pCodecContext-&gt;max_b_frames            = 3;
  pCodecContext-&gt;refs                    = 4;
  pCodecContext-&gt;directpred              = 3;
  pCodecContext-&gt;trellis                 = 1;
  pCodecContext-&gt;flags2                 |= CODEC_FLAG2_WPRED | CODEC_FLAG2_MIXED_REFS | CODEC_FLAG2_8X8DCT | CODEC_FLAG2_FASTPSKIP;  // wpred+mixed_refs+dct8x8+fastpskip
  pCodecContext-&gt;weighted_p_pred         = 2; // not implemented with interlaced ??
  pCodecContext-&gt;crf                     = 22;
  
  pCodecContext-&gt;pix_fmt                 = PIX_FMT_YUV420P;
  
  pCodecContext-&gt;thread_count            = 0;
  </code></pre>