我正在使用xuggler将一系列图像编码为MP4文件。我使用以下代码设置IStreamCoder
并指定H264编解码器:
// 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()));
产生以下输出:
Codec: CODEC_ID_H264
Resolution: 1280x720
Bitrate: 25000
Bitrate Tolerance: 1000
Framerate: 25.0
现在,当我指定MPEG4编解码器时,我得到以下输出:
Codec: CODEC_ID_MPEG4
Resolution: 1280x720
Bitrate: 25000
Bitrate Tolerance: 1000
Framerate: 25.0
如您所见,唯一的区别是ICodec
类型(MPEG4而不是H264)和预设的使用(使用H264编解码器时xuggler需要)。任何人都可以向我解释质量的巨大差异并告诉我如何解决这个问题吗?