I'm using xuggler to encode a series of images to an MP4 file. I use the following code to setup the IStreamCoder
and specify the H264 codec:
// 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()));
which yields the following output:
Codec: CODEC_ID_H264
Resolution: 1280x720
Bitrate: 25000
Bitrate Tolerance: 1000
Framerate: 25.0
Now when I specify the MPEG4 codec, I get the following output:
Codec: CODEC_ID_MPEG4
Resolution: 1280x720
Bitrate: 25000
Bitrate Tolerance: 1000
Framerate: 25.0
As you can see, the only difference is the ICodec
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?