Follow Slashdot stories on Twitter


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×
User Journal

Journal PhillC's Journal: Quick FFMPEG Codec Comparison Test: x264 vs xVid 6

Today I took the time to run a quick comparison test using FFMPEG for producing content with the x264 and xVid codecs. x264 produces H.264 content, while xVid encodes in MPEG4. Frankly, I was a little surprised with the results.

The input file was sourced from BBC Motion Gallery. It was an MPEG2 Program Stream with I-Frames, encoded at approximately 50Mbps. It also contained a single MP2 audio track at approximately 356kbps. To see the clip on BBC Motion Gallery, click here. The clip was chosen because it is only 2 seconds long, so I could transcode it quickly, and there is also lots of movement, so I expected artifacts.

The output file container is QuickTime MOV, the video bitrate around 2Mbps, the audio codec aac (through libfaac) at 128kbps. I performed a 1 pass and 2 pass encode with x264 and xVid. The output file was to be 720x404 in size, this is 16:9 aspect ratio. All files were played back on a Windows XP machine using QuickTime Player 7.1.3. Some cropping of the original MPEG2 was required to remove VITC at the top and some black padding left and right. An example FFMPEG command line I used is outlined below. As you can see, there are very few optimisations other than the base settings.

FFMPEG command for the second pass x264 encode:

ffmpeg -i 2573-9.mpg -vcodec libx264 -f mov -b 2000k -acodec libfaac -ab 128k -s 736x442 -croptop 34 -cropbottom 4 -cropleft 8 -cropright 8 -deinterlace -pass 2

The final output file sizes are as follows:

  • x264 1 pass: 599.558 kilobytes
  • x264 2 pass: 553.767 kilobytes
  • xVid 1 pass: 577.232 kilobytes
  • xVid 2 pass: 559.947 kilobytes

So, while xVid one pass produced smaller file sizes than x264 one pass, the x264 2 pass file is smaller than the xVid 2 pass file. Due to the short duration of the input file, no comparison of encoder speed could really be made. However, anecdotally from other ad hoc encoding jobs, xVid does seem to be quicker.

Now, to the real proof of the pudding, what was the quality like. Have a look at the following image file:

This is where I was surprised. The x264 files are on the left. 1 pass is bottom left. 2 pass is top left. The xVid files are on the right. 1 pass bottom right. 2 pass top right. Clearly, the 1 pass xVid file is superior to the 1 pass x264 file. I also believe that the 2 pass xVid file is slightly better quality then the 2 pass x264 file. Areas for close inspection (we're looking at the two top files here):

  • Bottom right corner. There is more blocking and artifacts on the x264 file.
  • Top right wing tip. The xVid file has better definition here.
  • The underside of the wings and tail. Again the xVid file has better definition.
  • The background fire. I think the xVid file has less artifacts and better definition in general.
  • As there aren't a lot of colours in the example video, it's hard to say which codec handles colour better, but there is obviously more depth in each of the 2 pass samples, compared to the 1 pass output.

That's pretty much it. I was surprised that to my eye the xVid content appeared to be superior to the x264 output. Perhaps with a more complext FFMPEG command and options this would have changed.

I'd be interested to hear other's thoughts and opinions on these two codecs.

This discussion has been archived. No new comments can be posted.

Quick FFMPEG Codec Comparison Test: x264 vs xVid

Comments Filter:
  • Hi Phill,

    By default the loopfilter is disabled, you should really enable it.

    ffmpeg -i inputmovie -vcodec libx264 -flags +loop output.mp4

    With friendly regards,
    • by takis ( 14451 )
      Hi Phill,

      Oh, and it seems CABAC by default is disabled too. Another thing you should really enable:
      -coder ac

      With friendly regards,
  • After a couple of tips on the FFMPEG user mailing list, I re-ran this test with some command optimisations. Specifically:

    • De-blocking loop filter enabled with -flags +loop
    • CABAC enabled with -coder ac

    New FFMPEG command example for x264, second pass is:

    ffmpeg -i 2573-9.mpg -vcodec libxvid -flags +loop -coder ac -f mov -b 2000k -acodec libfaac -ab 128k -s 736x442 -croptop 34 -cropbottom 4 -cropleft 8 -cropright 8 -deinterlace -pass 2

    New screen grab is here:

    http://farm3.stat []

  • I do most of my video editing in Sony Vegas, and the difference in rendering speed between Xvid and H.264 is huge. One-pass renders in Xvid take an average of about 2.5 times the run time of the finished video, while H.264 and Quicktime renders take 6 - 10 times as long as the runtime.

    Learning to mess with the Xvid "quantifier" settings helps.

    Reality = that for video you're going to deliver online, converted to Flash, either one does an acceptable job on 16:9 videos up to 960 px wide, which is about as big
    • by PhillC ( 84728 )

      I agree regarding the xVid encode speed. However, I'm not converting my footage to Flash for online delivery.

      About a year ago when I launched Kapital Moto TV [], I made a tough decision to deliver content as H.264 encoded QuickTime, embedded in the browser. I for sure took a hit on installed user base, but I really wanted to emphasise a quality viewing experience over what was available elsewhere.

      As it turns out, I made a pretty good decision. Now that the latest Flash player supports H.264 encoded MPEG-4

"Open the pod bay doors, HAL." -- Dave Bowman, 2001