Log in

View Full Version : GOP (I-frame) interval - ffmpeg vs XviD..?


Gew
28th July 2010, 22:30
Hi!

I just noticed something interesting. In Xvid (VfW interface) the default max GOP setting is 300. With ffmpeg, you set the value with "-g" (default is 12, which is DVD spec). Anyways, there seems to be one (giant?) difference between the methods these two are using. If I encode something with Xvid/VfW, and then examine the output file with GSpot, it first tells me an average value, which for the most times are waaay below the "nominal" 300. When pulling the same encode with "ffmpeg -vcodec libxvid -g 300", GSpot reports eg. "299.4 avg / 302 max". Also, I did "-g 300" so that max value should really be just that, 300, yet it's not.

Another funny thing, when I examine the VGS pattern, it's a very, errrhm, strict pattern of I-frames. I.e. exactly every other 300th frame is a keyframe. That's odd too, GSpot said "299.4 avg", but the pattern of exactly(!) 300 frames between each I repeats itself all through the video (I did look into it). Bug in GSpot, or something with ffmpeg? I also tried "-vcodec mpeg4" (the FMP4 variant). Also this one uses this, errr, should I say "primitive" I-frame count.

So, my conclusion is that Xvid/VfW comes with some sort of "artificial intelligence" that uses some sort of quantizer mechanism to determine when it's a "good move" to add I-frame. Whereas ffmpeg acts with no "estimation" at all, but just adds I-frame after set "-g" value. Is my conclusion correct?

Then I can't help but wonder, wouldn't this affect quality (in the benefit of Xvid)..? And if so, in what level? Is there only a marginal difference in result/quality between the two methods, or is it really worth not using ffmpeg just because of this?

I'm just curious!


Ty in advance~
Regards~

Motenai Yoda
29th July 2010, 02:15
If I remember should be difference between frames more than 40% = use I-frame the setting in vfw and enc_raw should be the maximum interval between two I-frames
too few I-frames can affect the quality if the difference between frames is too much that an P-frame or B-frame isn't sufficient or can be bigger than a I.

Jarek75
15th August 2010, 09:32
Gew, I have experiences similar to yours. For the last couple of days I've been trying to find optimal method for encoding videos under linux. I'm switching from Windows+VirtualDub+xvid. Trying libavcodec and xvid.

First I stepped into libavacodec, but after comparing a sample video I see a huge difference in quality (2 pass, same bitrate) between lavc and xvid. Lavc doesn't set the key frames properly, is unable to detect scene changes. Only after introducing some advanced settings and changing sc_threshold to a big negative number I managed to force him to set the keyframe on the scene change. Without them lavc gave the k-frames exactly on these gop intervals.

Comparing the quality of a single frame is again in favour of xvid. Lavc gives more squares, even with the most precise and slow settings. Conslusion: make it only with xvid.

How to use xvid? Ffmpeg doesn't give the full control on the xvid options. Transcode (1.1.5) is buggy, it's hard to get it working and inserts some misplaced frames in the video. That's from my point of view. Fortunately mencoder gives full access to the xvid options and at the moment I'm giving it a chance.

Xvid can be really slow under linux, as lam_das stated in xvid encoding too slow in linux (http://forum.doom9.org/showthread.php?t=121327) thread. But getting latest cvs source (that makes xvid version 4.3) instead of the latest stable 1.2.2 gives it a kick and the speed begins to be ok.