|- preamble -|- source -|- building -|- downloads1 -|- end -|


HandBrake: Conversion of various video and audio formats to a multiplicity of video and audio formats. As the site announces - Sunday, Nov 23, 2008 - HandBrake 0.9.3: Released! - with a massive number of improvements...

Download Source:

In a root folder of your choice, do -

   svn co svn://svn.handbrake.fr/HandBrake/trunk HandBrake

Got 1816 Files, 17,975,072 bytes of source...


In a quick review of the source, I note a quite large 'macosx' folder, so can see the MAC port is quite active. It appears the 'windows' source is in C#, with Handbrake.sln and HandBrake.csproj build files... EEK, trying to load this solution into my MS C# Express 2005 shows it was created with a LATER version, so I must SWITCH machines... since I do all this through batch files, I just transfer and run updhb.bat again ;=))

So I downloaded into my Vista machine, and loaded this build set in MS C# Express 2008, built, and ran the application... But it FAILED on running the 'main' application - HandBreakCLI.exe, because this HAS NOT BEEN BUILT!

Checking in the 'docs' folder, I can find files BUILD-Cygwin, BUILD-Linux and BUILD-Mac, BUT no BUILD-Win32 or the like... It seems the 'developers' use the Cygwin - quasi-unix-environment - to build the main EXE, HandBreakCLI.exe!!!

Ubuntu Build

So to get some 'experience' in building HandBreakCLI console executable, I decide I should give it a try in Ubuntu (x86_64 linux 8.04) first, so I download the source, and install some required packages - the doc/BUILD.Linux gives a list, but I had to change 'libwebkit-dev' to 'libqtwebkit-dev' and 'libwebkitgtk-dev' :-

$ svn co svn://svn.handbrake.fr/HandBrake/trunk hb-svn
$ cd hb-svn
$ ./configure --launch

After about 7-8 minutes it ended with an ERROR! I did it again, just to make sure!

Looking and reading around I discovered the Ubuntu 'yasm' (the ASM assembler) is quite old, v.0.5.0, so ended up downloading the latest source from http://www.tortall.net/projects/yasm/wiki/Download - through SVN :-
$ svn co http://www.tortall.net/svn/yasm/trunk/yasm yasm
There is a certain satisfaction, and FUN, in building your own from source ;=)).

The $ ./autogen.sh did it all, but the default install was to /usr/local/bin, so I ended up uninstalling the old 'yasm' version using the Synaptic Package Manager, and doing a new $ ./configure --prefix=/usr; $ make; $ sudo make install, and I had version 0.7.99 installed in /usr/bin - PERFECT ;=))

I trashed the existing hb-svn 'build' directory, and started again, and this time the final output was -
duration: 7 minutes, 58 seconds (478.11s)
result: SUCCESS

and I had my Ubuntu HandBrakeCLI built ;=))
The two failed logs are here - build1.log.txt and buld2.log.txt, and the SUCCESS build3.log.txt...

So the Ubuntu build was relatively painless. I hope the native MSVC9 WIN32 will be similar...

Native WIN32 with MSVC9

There appears to be no build files for this console application, only the GUI, but it looks like the libhb just includes all the files in the 'libhb' directory, so I wrote a perl script, builddsp.pl, to read these sources, and create a DSW/DSP set of build file to reside in a 'build/msvc' folder. Then loaded and converted these with MSVC9.

I decided on a progressive approach - as errors arose, I would fix them and continue... On the first few files, I ran into problems that although they are C files, they are written in C++ style. By that there are MANY occasions where context variables are created after existing code, like :-

int foo( int a ) {
    int i = 0;
    i += 5;
    char * buf = (char *)malloc(100);

While this is perfectly legitimate in C++, the MSVC9 compiler gives an ERROR, when compiling it as 'C'! After I had corrected quite a few modules, putting in #ifdef _MSC_VER switches, I started to see it was ubiquitous throughout the code! Although I have not often used it, there is a compiler switch, /TP, which instructs the compiler to treat the file as C++. Then this particular error went away.

There were several other 'error' repeated many, MANY times, like :

hb_buffer_t * p = calloc( 1, sizeof (hb_buffer_t) );

Since 'calloc(...)' is prototype returning a 'void *', MSVC9 insists that the cast be added like :-

hb_buffer_t * p = (hb_buffer_t *)calloc( 1, sizeof (hb_buffer_t) );

This was very frequent, and included some other like functions prototyped to return a 'void *', and some assigns... unfortunately it appeared in just about every module... 'calloc' alone is used over 100 times ;=()

Most 'fixes' were quite straight forward, and most would also 'work' under a GCC compile! There are some where I have put a 'CHECKME!!!' to signal that this should be re-checked, and one table generation in stream.c I know will presently generate an incorrect table, and MUST BE FIXED!

After several MONTHS of effort, eventually got a native WIN32 MSVC exe built, but still to TEST it thoroughly... but here is the ORIGINAL source I started with, and the MASSIVELY modified source that finally built HandBrakeCLI.exe...


Date Zip Size MD5
18/09/2009 original-src.zip 34,915,723 3569a8bc0068ea7f3767e34ecd5449c7
2009-10-15 modified-src.zip 38,795,656 5d209db12c2bbfffc2675df396fcce22
2009-09-29 static-libs.zip 43,081,706 df492ffd43f98e7122238cf59ae85fb3
Take care downloading and running executables from the web!
2009-09-28 runtime-win32.zip 11,453,450 c33927089aaf3c52ccc3f6eb211cd445

As stated, still to be TESTED more thoroughly...

*** To be continued ***



checked by Tidy  Valid HTML 4.01 Transitional