If you were looking for MP4/Mpeg4 Part 10 CoreAVC vs FFmpeg video codec performance review then click here

Codecs:

Though there are several codecs that perform the encoding owing to the universal use of this encoding in dvds, common implementations are Nero, Divx, Xvid etc. Among these arguably the most popular codecs are Xvid and Divx. We will be seeing side by side comparison of both in the article. You can find both codecs individual history on their wiki pages. I find the history of Divx quite amusing,They adopted their name Divx to mock a company that used to charge users for viewing by the hour and themselves used spyware in their later version hence becoming a subject of mockery. You might have already noticed that “Xvid” is “Divx” backwards.

I will talk of decoding performance here. Decoding probably makes much more sense to a normal user as encoding is done by few but everybody decodes videos. Decoding is quite a subjective criteria hence besides my own comments I have also attached screenshots that allow the user to make his/her own judgment. The codecs were taken from Final build site.

Xvid
There is a very good chance that any video that you come across is encoded with Xvid. Across my search of encoders I found Xvid is the most preferred one for encoding. Its opensource hence free, much more configurable hence lets you draw the last byte’s worth. Though it seems logical that if video is encoded with encoder its respective decoder should also be the best, however I found the results didn’t fare as I expected.

Divx

The good old closed source version. Divx is costly and costing is on per PC basis hence encoding costly. Decoding can be done for free using their web player. The pro version is not free however there are other ways of using the codec in Media Player classic shipped with Klite Codec as explained below.

Here is the screenshot of Gspot codec analyzation. This provides the codec information with which the file was encoded in:

2. Audio Encoding was done by MPEG-1 Layer 3 more popularly known as MP3

3. The default resolution is 352×272 and should be judged at that resolution

Further information can also be seen from the screenshot

PS: you can also use other codec information utils like AVI codec etc.

Following are the screenshots taken from the video with different filters(All the left screenshots are Divx and right ones are Xvid)

Click the pics and view them at full-size and compare them. As the videos clearly depicted the Divx Filter far outperforms Xvid Filter in visual apeal.

There is a very important decoder that I have not mentioned here, that is the FFmpeg decoder(default decoder in most open players like mplayer, media player classic and vlc). This decoder generally uses libavcodec to decode the media files and even though the performance is not as good as the above decoders but it is good enough but the difference in CPU usage is extreme. Ex for a normal movie where Divx and Xvid take as much as 25-30% CPU usage, FFmpeg will take barely 10-15%. So if its quality you are looking for then look no further than Divx but for performance nobody matches FFmpeg

So overall the results are quite ambigous. If you are looking for quality then Divx, for free encoding/decoding Xvid and for decoding performance FFmpeg . You can download the filters from here, and you can learn how to switch your filter from here. So what are you going to do with your player???

MPEG-4 is used for AV data for web (streaming media) and CD distribution, voice (telephone, videophone) and broadcast television applications.MPEG-4 adds new features such as (extended) VRML support for 3D rendering, object-oriented composite files (including audio, video and VRML objects), support for externally-specified Digital Rights Management and various types of interactivity. AAC (Advanced Audio Codec) was standardized as an adjunct to MPEG-2 (as Part 7) before MPEG-4 was issued.The key parts to be aware of are MPEG-4 part 2 (MPEG-4 SP/ASP, used by codecs such as DivX, Xvid, Nero Digital and 3ivx and by Quicktime 6) and MPEG-4 part 10 (MPEG-4 AVC/H.264, used by the x264 codec, by Nero Digital AVC, by Quicktime 7, and by next-gen DVD formats like HD DVD and Blu-ray Disc).

If you were looking for MPEG 4 Part 2/ AVI video codec performance review: Divx vs Xvid then click here

Codecs:

As told previously 2 parts of MPEG-4 format are popular. There are several codecs available that implement MPEG-4 with different level of perfection, popular ones are Quicktime(Part 10), FFmpeg(Part 10), Xvid(Part 2), Divx(Part 2) and CoreAVC(Part 10). After consulting several forums, I found 2 of those very talked about CoreAVC and FFmpeg. I have compared the 2 codecs below.

FFmpeg
Whether you are a codec geek or not, this is the most probable codec that you have been using since time immemorial. Its free, opensource, can allow a lot of tweaking, plays a major number of containers and codecs. I will try not to go beyond H.264 in this article but one thing is for sure, whether you are using CoreAVC or not, you definitely have to use FFmpeg due to its overwhelmingly large number of codec compatibility.

CoreAVC
Its a closed source alternative for decoding H.264, infact its one of the accepted formats for Blue-ray. When it came out it astonished everyone with the sheer speed and performance outputs. Its known to exceed several hardware implementations (reminds me of John Carmack implementation of square root in Quake 3 which was faster than FPU). Corecodec people call it the fastest codec on earth.(and I am nobody to argue).

Left one is CoreAVC and right is FFmpeg

Doesnt take a rocket scientist to notice that better one. However when I discussed this on outside forums, I faced considerable shouting and screaming so I did more tweaking and testing and found another bit of information that convinced me to use CoreAVC for good.
Left is CoreAVC and right is FFmpeg.
Top is W/O post processing and bottom is with Post Processing

Difference between CPU usage when using FFmpeg and CoreAVC is huge. It can be seen from the above CPU usage or by seeing CPU cycles consumption . Considering that I have a Core 2 duo system with 1.8Ghz this difference is a substantial one, infact with preprocessing the player hung at 100% cpu usage in FFmpeg.

I found out to my amazement that Corecodecs are actually the fastest codecs in the world. I used all possible codecs at my disposal(VLC, ffmpeg, quicktime, windows media player and Nero) but CoreAVC not only gave better performance compared to all of them but also astonishingly smooth one at that. I ran it on 1080p trailer of 10000BC on MPC using quicktime alternative(had to rename .mov to .hdmov to use coreAVC) and performance was mind boggling.
Bottomline, I’d suggest you one thing. just go right now to Final build site and download the coreavc format and start using it. You can find out how to do that here.

Download the codec. Though there are several sites that provide opensource codecs for free, there are few that provide closed source too. I have found Final build site to be quite good and provides almost all codecs. If you dont have any codecs at all I do suggest you to install Klite codec Pack and have some basic codecs to start with.

Step 3:

If you have started using Media Player classic without any change then you are most probably using FFmpeg codecs. These are very good codecs and use libavcodec for most of the decoding. It decodes most formats however not all of them perfectly. Now that you have your new filter installed.

Open the options window in media player classic(by pressing ‘o’ or through right click menu )

Go to External filters option. Now in the right side of the window select Add Filter

You will get an elaborate window with a plethora of options. Select your codec

If your codec is not available there you will have to put a little more stress. Open the folder that your codec installed in.

find a file with .ax extension in that folder and put it in filters folder inside Klite Codec Pack folder

Now you should click browse in the bottom left of codec window and select the filter inside filters folder. You can browse to select ax file from the folder it was installed but needlessly adds a dependency.

After selecting that filter go the right of the window and click Prefer among the 3 options(prefer, block and merit)

Recently, I came across this problem of adding a scripting interface to an application that we were developing as a part of our term project. Let me describe more details about the project and the problem. The project that we were working on is all about generating Random Graphs and their analysis. A little research for libraries that would simplify our task yeilded an open source gem JUNG. As this post is neither about JUNG nor opensource I would try to talk as little as possible about their coolness. Some serious effort for a couple of days from my beloved friend Praveen resulted in this java beast.

The app has more tools for network analysis than this simple visualization like plotting the Degree Distribution Vs Rank, Pk Vs k, Clustering Coefficient Vs Rank, Betweenness centrality Vs Rank plots. Despite this much effort we are not confident about getting the best possible grade due to the lack of good innovation 🙂 ( I guess I am talking big here). So, here comes the small innovation. The networks that we analyse are generated using standard models like Barabási–Albert (BA) model, Erdős–Rényi model etc. In this way the application is limited and finds little use as these models had been analysed fully in every possible angle. So the application needs to support new models. But, writing code for each and every model is too complex and inefficient. The obvious path then would be to somehow express a network. The simplest way for the end user would be to express the network in english :). But poor computers yet donot understand english completely. So, the alternative is to ask the user to express the network in a language that computers can understand. The essence is that we need a scripting interface to express the network in our application. A single problem can have more than one solution and with opensource its more true. After all opensource is about choice. We had a couple of alternatives for this problem too. There are lots of embeddable scripting languages at our disposal.

We finally decided to pick java for this purpose. The solution that we picked might seem odd as it comes second to last in the scriptometer rankings. But, it has its own benefits. The obvious thing is the simplicity and elegance of the soultion.

There is no need for us to learn a new language

There are no integration costs. ( If you have missed the point, we programmed the whole application in java itself )

Once we have decided that the end user expresses the network in java, we need to chalk out a solution for running his network model to generate the set of vertices and edge. The problem boils down to two things

Compile the code that he has written from the application itself.

Execute his code to generate the network graph.

So how do you compile java code from java application. There are two solutions to this problem too. The first one is using an undocumented java class com.sun.tools.javac.Main. The other solution is to use a more standard and documented api available from java 1.6 onwards. We chose the earlier one as the final application has to run on a machine with only java 1.5, though that means using undocumented and unsupported functions. Time for some real java

Remeber to include the tools.jar shipped with the jdk in the classpath. Main.compile is basically a wrapper over the javac ( javac is not required on the machine running this application. ). It does the real job of compiling the java source code and producing the class file. The arguments are self explanatory.

Once the class file is generated it has to be executed. This process is much simpler and doesnt require any undocumented classes ( aah releif !! ). Java has a class called Class. Instances of the class Class represent classes and interfaces in a running Java application. One can create a new instance of any class using the member function newInstance(). Once a new instance is created it has to be typecasted into a class that the compiler knows at compile time so that we can invoke its methods. So we have an abstract base class called Model that models all network models. Any network model defined by the user inherits this base class and also implements an abstract function defined in the base class Network called generate. Once a new instance of the user’s network model is created, it is typecasted to the base class Network and the generate method is called on this object to generate the network. More code follows …

Well, you are an opensource user. Your geek rating is much higher than any of your other puny friends on facebook. You bask in the glory of being clean and untainted. But dont confuse being opensource as “not being evil”. The real trick is to use the good will of opensource and still use it for your nefarious (defination) purposes. Behold the sins of Opensource and how/where to use it in your own company:

As Strategy (aka Greed): Most evil are those who employ opensource as a strategy, this not only allows them to publisize there product but also gives them a GNU loving status. Google like always leading the way with Google Gears and Libjingle. By making Gears opensource it caused a 3 way effect

It allowed the people to look into the code and ensure that there are no google spies sitting in it, hence building trust.Without this nobody would opt for it

It also became instant favorite to all those who hate The Microsoft way, giving them the satisfaction of using an opensource alternative on an opensource platform(firefox).

Allowing other people to step in with it and start making more tools to replace more softwares(ZOHO, Offline WIkipedia etc)

So using it as a stratigic weapon you can assasinate a lot more quickly than otherwise.

As a User (aka Gluttony): You reading this blog in firefox and me writing it in wordpress doesnt make things a whole lot better. If you have used a product of opensource and have never cared to:

Submit a bug report.

donate for it(and are never planning to).

Contribute back.

then you are evil. You are another one of those selfish people who just wanna use the product for free and run away with the benifits. I wouldnt blame you for it but we are all sinners

As a developer(aka Pride): If you are a developer associated with a opensource community because of any of the following reasons then you are also a sinner:

Even if you see your own project suffering because of unsufferable GUI, you still stand by and keep working on core internal library which is already ruthlessly efficient. Since GUI is one of the most boring things to work on you choose to ignore it and because of that your project suffers. This is the sin that leads to poor interfaces of so many opensource software.

You have been laid off, and just want to code to keep your skills sharp and to build your CV and have no interest in the concept of “greater good” and benifit of all man kind.

As a startup(aka Sloth): If you are a startup or for that matter any company and you are using opensource software because of any of the reasons then you are also sinners:

Using your expert skills you are able to disprove Microsoft’s TCO model and use opensource as cheap software.

Use plenty of opensource tools in your company but have never released any of the scripts etc neither have cared enough to put even a simple logo on your official site.

You rely of free service of opensource community that is 10 times larger than that of any company’s support staff.

Worse are all are those developers who use the free experience provided by opensource community in development of features that they eventually want to put in there own software(best oppurtunity is GSOC).

Disclaimer: I’d like to apologize to anybody who feels offended. This article fundamentally represents how opensource is practically being used by different catagory of people(coders, users and companies). There are several other ways of employing/deploying opensource which will be discussed in future articles.