COMPILING FFMPEG ON WINDOWS

10/25/2009


The best Windows-compile tutorial I've found is the one on the FFMPEG Wiki. It's about as good as it gets, but there were still some ambiguities and 'gotchas' left laying around the Wiki that I had to parse through to get everything working, they were fairly minor and everything worked pretty much as-advertised.

Since I had pretty good luck with this and I have seen several threads where other people haven't, I thought it would be worth the effort to at least show the steps I took, maybe this will be useful to some.

None of this is hard, you don't have to be a programmer to do it, you just have to follow along.


FIRST, GET THE STUFF:
1.) If not installed, get Winzip and WinRar and install them.
    (for all the tar, bz2, 7z, gzip, rar, etc files updates come in)

2.) Make a directory off your root called 'ffmpeg-zips'.
    Examp: C:\ffmpeg-zips, G:\ffmpeg-zips, etc.

3.) Download these files to C:\ffmpeg-zips :
    (current versions as of the date of this guide...)
     from mingw.org: 
              MinGW-5.1.6.exe
     from mingw.org: 
              MSYS-1.0.11.exe
     from tortoisesvn.tigris.org:
              TortoiseSVN-1.6.6.17490-win32-svn-1.6.6.msi  

I've linked the home-pages rather than the actual files so you don't inadvertently end up with a less than current version.

Later (not yet), you can navigate to the C:\ffmepeg-zips folder where you dumped all this stuff, double-click on the files and install them to the folders you're going to make in the following step.


SECOND, INSTALL THE STUFF:
1.) Make a directory off your root called 'dev'.
    Examp: C:\dev, G:\dev, etc.

2.) Make directories off ..\dev called 'mingw' and 'msys'.
    Examp: C:\dev\mingw, C:\dev\msys

3.) First, install MSYS to C:\dev\msys\
    Note: if you install mingw first, msys will try to locate it and incorporate 
    it's path, this won't work because of a bug in the script that msys uses.

4.) Next, install mingw to C:\dev\mingw\

5:) Install TortoiseSVN to anywhere you want (default is ok...).
Here's what you have (I added the \docs directory later, you don't have to do this).
install01.jpg

THIRD, TWEAK MSYS/MINGW:
1.) Navigate to C:\dev\msys\bin\

2.) Copy 'make.exe'

3.) Paste into C:\dev\mingw\bin\

Note: mingw's 'make' doesn't work with the config script for ffmpeg, it gets through
most of it but won't produce an executable.

4.) Verify that C:\dev\msys\home\<your-name>\ exists.
    Examp: C:dev\msys\home\tony
    Add it, if it doesn't.

5.) Make a diectory under ..\<your-name> called 'ffmpeg'
    Examp: C:dev\msys\home\tony\ffmpeg

6.) Make a directory under ..\ffmpeg called 'svn'.
    Examp: C:dev\msys\home\tony\ffmpeg\svn
Here's what it should look like:

dtree.jpg

7.) Edit C:\dev\msys\etc\fstab

This is just a text-file that provides 'bindings' for msys to 'mount' filesystems. Open it in notepad, make it look like this:

#fstab
#You can use a # as the first character on the line 
#as a comment indicator.Blank lines are ignored.

#Win32_Path	Mount_Point
g:/dev/mingw	/mingw
g:/perl	        /perl

Substitute your Drive letter for g: in this example. Check to make sure notepad didn't append a '.txt' to fstab, rename it to 'fstab' if it did. If you have perl installed you can give it the path, if not, leave it out. What you're doing here is letting msys know where to go to get to a compiler (gcc in the mingw directory tree).


FOURTH, CHECKOUT THE SVN

If you haven't rebooted since you installed Tortoise, do it now before going any further.

Tortoise is a subversion (SVN) client. After it's installed, don't look for a desktop icon or a taskbar shortcut, there isn't any. Instead, just right-click to get a context-menu and you'll see the Tortoise client's options.
tortsvn.jpg
For the context-menu to work correctly, you should have your mouse over windows-explorer or vista-explorer. Your file-manager should have 'focus', since the interface is actually a shell-extension.

1.) Click 'Checkout'
svncheckout.jpg

2.) Enter the lines you see here: URL of repository: svn://svn.mplayerhq.hu/ffmpeg/trunk Checkout directory: G:\dev\msys\home\tony\ffmpeg\svn (Substitute your Drive-letter for G: and 'your-name' for 'tony').

Let it run. When it's done you'll have the entire source-tree of ffmpeg in your ../svn directory.

Since you now have ffmpeg checked-out, if you were to right-click again when in your file-manager, you would see a somewhat different context-menu:



Now, clicking on update, you would get any new files that had been committed since your last checkout:



FIFTH, CONFIGURE/MAKE FFMPEG

Up to this point, you could do everything from Windows, using your file-manager. From here on out, we'll be using MSYS and the default-shell command-line to finish-up.

Even though a lot of advice says to insure the latest Bash-shell for MSYS is used, I found the default shell worked fine, but you are welcome to change if you feel the need.

Fire-up MSYS by clicking on the desktop icon it installs:

msys.jpg

Remembering to use your own name, enter this stuff at the prompts:

configure.jpg


'pwd' prints the working directory, in this case it verifies /home.
'cd' changes directories, here we want the svn directory.
'configure' runs the script that sets up ffmpeg for compile, you give it any compile options you want it to use, in this case we use the Wiki-example default option.

It takes a while before anything happens, but your system isn't hung, it just takes a while.

After it's done, you get your prompt back along with any messages configure wants to pass along. In this case, since I haven't changed anything in my original configure arguments, it simply reports that nothing's changed.

configure2.jpg


That's actually the biggest hurdle, if you can get a good config, the 'make' is automatic (as long as you swapped-out the mingw-make for the msys-make, as was pointed out earlier...)

So then, the next command is simply: make...

make.jpg


This will take awhile, too. As the Wiki states, you're compiling the entire source-tree from scratch, be patient.

compile.jpg


When it's done, you get the prompt back. At this point you can just run ffmpeg.exe out of your ../svn directory (since that's where we built it), just to see if it works:

run.jpg


ffmepgexe.jpg


At this point you can also choose to do a 'make install' from the command-line, which will reuslt in several files, including a copy of the executable, being put in the following directories under ../msys:

make-install


And that ends this guide. What you've accomplished is installing a build-environment on Windows for ffmpeg that you can now use for development or just to keep current.

I should point out that the only authoritative (and also the 'best') source of information for any further forays into ffmpeg development is the Wiki. This guide is just a 'hand-holder' to help get past any ambiguities that may have been encountered in other guides.

Any further questions you might have will be covered in the Wiki or can be addressed to several forums and lists that specialize in ffmpeg and ffmpeg front-ends (such as WinFF or Avanti).

Oct. 25, 2009
Tony Taylor


Copyright © 2009 A.Taylor, all rights reserved