1

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

H264 encoded video

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

MPEG4 encoded video

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?

Sonoman
  • 3,379
  • 9
  • 45
  • 61
  • Open it in a video player and see what the resolution and bitrate are. Most players show them somewhere in the menus. If the player shows a low bitrate then that's where your problem comes from. – sashoalm Dec 02 '11 at 08:56
  • 1
    Turns out I was being an idiot and applying the bitrate as I would on the command line with ffmpeg. e.g. I set the bitrate at 2500 assuming 2500Kbs but it was in actual fact 2500bps. Multiplying this by 1e3 gave the desired resolution. On the flip side now, why does the Mpeg4 codec ignore all bitrate settings? – Sonoman Dec 05 '11 at 09:47
  • 1
    No idea. You'd need to look at the code to know why. Probably it has some minimum bitrate and it reverts to its defaults if it sees something less than it. – sashoalm Dec 05 '11 at 10:56

0 Answers0