title: H264 encoder settings
body: <p>I'm using xuggler to encode a series of images to an MP4 file. I use the following code to setup the <code>IStreamCoder</code> and specify the H264 codec:</p>
  
  <pre><code>// only set if codec is H264
  Configuration.configure("/usr/local/xuggler/share/ffmpeg/libx264-hq.ffpreset",
              outStreamCoder);
  
  outStreamCoder.setNumPicturesInGroupOfPictures(12);
  outStreamCoder.setCodec(codec);
  outStreamCoder.setBitRate(videoSettings.getBitrate());
  outStreamCoder.setBitRateTolerance(videoSettings.getBitrateTolerance());
  outStreamCoder.setPixelType(IPixelFormat.Type.YUV420P);
  outStreamCoder.setHeight(videoSettings.getResolution().height);
  outStreamCoder.setWidth(videoSettings.getResolution().width);
  outStreamCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
  outStreamCoder.setGlobalQuality(0);
  fps = IRational.make((int) videoSettings.getFramerate(), 1);
  outStreamCoder.setFrameRate(fps);
  outStreamCoder.setTimeBase(IRational.make(fps.getDenominator(), fps.getNumerator()));
  </code></pre>
  
  <p>which yields the following output:</p>
  
  <pre><code>Codec: CODEC_ID_H264
  Resolution: 1280x720
  Bitrate: 25000
  Bitrate Tolerance: 1000
  Framerate: 25.0
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gZER0.png" alt="H264 encoded video"></p>
  
  <p>Now when I specify the MPEG4 codec, I get the following output:</p>
  
  <pre><code>Codec: CODEC_ID_MPEG4
  Resolution: 1280x720
  Bitrate: 25000
  Bitrate Tolerance: 1000
  Framerate: 25.0
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/7VWOS.png" alt="MPEG4 encoded video"></p>
  
  <p>As you can see, the only difference is the <code>ICodec</code> type (MPEG4 instead of H264) and the use of the preset (which is required by xuggler when using an H264 codec). Can anyone explain to me the huge difference in quality and tell me how to resolve the issue?</p>