Thursday, July 29, 2010

FFMpeg - Building on Windows

FFMpeg is probably the most widely used Encoder/Decoder library. It helps you when are working in a project that involves video processing. As with any open source project, it has very limited documentation. An article by by Martin Böhme (Using libavformat and libavcodec) and Stephen Dranger (FFmpeg and SDL Tutorial) were the only good articles available around. Apart from this, you might need to look into OutputExample.c that comes with the FFMpeg source code. I had a very hard time trying to learn from these tutorials and use 'libavcodec' library in my programs.This has been my prime motivating factor to start this blog.

The first thing about Open Source projects is, they dont distribute binaries. They distribute only the source code. So it makes your life harder to understand to download the source code, setup the build environment and then take a build. This process, though, is inevitable. If you really wish to skip the building process and get only a build, you can get them here. (P.S. these builds are outdated. If you plan to use it in your commercial application, you might need to search for an LGPL build. Else you will end up in FFMpeg's Hall of Shame)

Let's start with the build process. :)

Stuff to Download
  1. Download MinGW from here.
  2. Download MSYS from here.
  3. Download updated bash for MSYS from here.
  4. Get the latest snapshot of ffmpeg from here

Installing MinGW
  1. Click 'Next'
  2. Choose 'Download and Install' and click 'Next'
  3. Click 'I Agree'
  4. Choose 'Current' and then 'Next'
  5. Choose 'MinGW base tools' and 'MinGW Make'
  6. Choose Destination folder as 'C:\MinGW'
  7. Click 'Install'. The download will take some time and then will complete the installation.
  8. Click 'Next' and then 'Finish' to complete the installation.
Installing MinSys
  1. Click 'Yes'
  2. Click 'Next'
  3. Agree to the license agreement by clicking 'Yes'
  4. Click 'Next'
  5. Choose 'C:\msys\1.0' as destination folder and click 'Next'. Click 'Yes' to create a directory if not already there
  6. 'Installation for i386 based CPUs' should be selected, Click 'Next'
  7. Click 'Next' and then 'Install'
  8. The command window that opens will ask if you wish to continue with post install, type 'y'and press enter.
  9. Type 'y' and press enter when it asks if you have MinGW installed.
  10. Type 'C:/mingw' when it asks for your MinGW installation. (without quotes)
  11. Type 'y' when if it asks for adding mount bindings.
  12. Press enter and then Click 'Finish' to complete the installation.
Building FFMpeg
  1. Extract CoreUtils to a folder. Copy the contents in the extracted 'bin' folder to "C:\msys\1.0\bin"
  2. Extract the ffmpeg sources. I’ll assume you’ve extracted them to c:\work\ffmpeg .
  3. Open MSYS and navigate to C:\work\ffmpeg
  4. Type "./configure --enable-memalign-hack --enable-shared" and press Enter. --enable-memalign-hack is to specify that you need windows binaries and --enable-shared is to specify to build 'libavcodec.dll' and 'libavformat.dll'
  5. By default, it is an LGPL build. You need specify -enable-gpl. For more info on command line arguments, type ./configure --help
  6. Type 'make' and press 'Enter'
And there you have it, your ffmpeg binaries are ready to be used.

I have personally verified all the above mentioned steps, but then you may face problems during the whole process. The following links might of use in that case.

Installing MSYS

Building ffmpeg on windows

Building FFMpeg on linux is fairly easy. I have not tried building it on other platforms.


aawaleh said...

I think these are very very outdated routines that you are posting, new versions with require different form of installation, I've wasted precious time on installing outdated versions, and thank you so much for wasting my time

Rmn said...

Am really sorry, this was posted about an year ago July 2010. And the versions I have referred in the post were the latest ones at that point of time. Let me see if I can update it some time soon. But I believe the procedure to build the new dlls should essentially be the same.

aawaleh said...

I tried your steps but after installing the latest msys 1.0 and mingw I could not even open either of them, is there a compatibility issue, cause Im on Vista OS?

Rmn said...

This link suggests that you should choose 'n' during the post install of MSYS on Windows Vista.

Looks like there are compatibility issues on Vista. Let me know if this solves your problem.

aawaleh said...

No It didn't work out, although I'm on vista 32-bit & the link is for vista 64-bit, I've tried the link suggestions but without a result !

aawaleh said...

So anyway, although I did not manage to install the Minwig & Msys yet to get ffmpeg working on windows because of some silly compatibility, do you know how can I use ffmpeg on Visual basic 6.0, cause what I want to do, Is to open and play a media file and then compress it using the ffmpeg built in codecs, to compare between the compressed videos and see the effects for studying purposes.

Rmn said...

Will VC 6.0 be sufficient for you? If so, you can find the post on it here..

aawaleh said...

Right, but ever since I've been trying to download visual basic 6.0 c++, but I couldnt as I had error messages during installation, do you know a link where I can find the visual c++ package, and would I be able to use this tutorial in Visual Studio 10 2010???

Rmn said...

Yes, it should work with VS C++ 2010 as well. But the places where you link the libraries will be different from VC 6.0

aawaleh said...

And what are these different library links procedures?

Rmn said...

They place in VS 2010 where you point to the directories where you have ffmpeg libs and dlls. They are different from the VC 6.0 snapshot shown in the post.

aawaleh said...

Ok-In VS 2010 I created a C++ win32 console application, empty project named if (ffmpeg), now there is 4 default folders,Ext dependencies, header, resource and source files,
then I right clicked on the ffmpeg solution to add a folder, note - in VS 2010, its not named a folder but named filter because I noticed the folder icon, then I added a filter named it libraries, I then added all (avcodec.lib, avformat.lib, avutil.lib), my query now is and I'm I right so far and whats the next steps??

Rmn said...

This is not a post on project settings in visual studios 2010. Simple search on google will help you.

aawaleh said...

That did not help me at all, First of all you posted this link and did not mention that it is incompatible with windows vista, so you have wasted my time dearly, and when asked if I can use it in viusal studio 10, you posted a link that is completely useless and not helpful.

aawaleh said...

I believe you are a complete fraud, not helpful and not aware of the incompatibility here, when asked HOW can use it in VS 2010, you posted a link that was bullshit.

Rmn said...

With all due respect, if you cant understand what that link points out, I guess you shud first learn how to create programs in VS 2010. Dont expect yourself to build programs with ffmpeg if you are not comfortable with visual studios.
Stop talking abt me wasting your time. If you dont like this post, there are plenty of posts out there which wil help you. Atleast I took the time to share my knowledge with others which I had learned. You need to respect authors before you start speaking. You dont like this, thank u for reading.. there are plenty of othee sites available. Go search for the stuff required. Seriously, I have spent just too much time responding to u.

Vin said...

Hey thanks for the post, was able to get it to work with your help!

Now to compile with libx264..

Rmn said...

My pleasure Vin

ram said...

Hey Rmn
Is this the latest way to build ffmpeg in windows? Do u have anthying later than this.
thx in adv,

Rmn said...

This is how I built about year and a half back. I think it shud be still valid to compile on windows xp. I haven't given it a try in recent times.

If you need only the binaries, you may consider downloading it from

ram said...

I downloaded the binary from I included them in my visual studio c++ project. Now I am getting this error
"fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory"

Is there anyway to fix this. guess this is for c-99 compatibility which is not supported in VS2008.

ram said...

i followed the instruction mentioned above. When I type in "./Configure --enable-memalign-hack --enable-shared"
it came out with an error, 'yasm not found, use --disable-yasm for a crippled build'. I proceeded with it and made a build. But when I run the exe from the build, it crashes. Can you enlighten me little bit on the error I mentioned.
P.S, I never used linux in my life and I run all these commands in windows with msys/mingw environment.

Anonymous said...

Dear ram im also tried above steps. Im also geting the same error message
"yasm not found, use --disable-yasm for a crippled build'."

Then i disable it and run then it propmts some other error messages and suggestions to configuration options, then i tried with that suggestions. But finnaly build faild.
So cuold uoy please share the dlls and header files (and libs also) that we could use with VC6.
Many thanks in advance, hoping a help from u.

JFG said...

If you get "yasm not found" error message, you need to manually download it from here:

Get either Win32 or Win64 version, depending on the architecture of your OS, rename the file to "yasm.exe" and place it in "C:\mgwin\msys\1.0\bin" or wherever you installed MSYS.

The build process should go on after that. You might get "pr: command not found" errors but these are only the inability of ./configure to create a log file. No real problem there.

louie said...

Okay, this worked for me except my ffmpeg.exe complains about missing libraries (like avcodec-54.dll) if they are not in the same directory.
Do you know how to statically link these?
Thank you.

Someshwar Sutar said...

Dear Ram,
please help, I want to run the ffmpeg sample programs with eclipse on windows.I Google a lot but, I do not found any suitable article or help. Please tell if there are some other ways to test and run the ffmpeg samples.

Raja Manikandan said...

I have never tried running ffmpeg on Eclipse in Windows. However, I think that once the DLLs are built, you should be able to statically them to your eclipse projects like any other windows dll. I have not worked on this, so i may be wrong.

ninest123 said...

moncler, moncler, pandora jewelry, pandora jewelry, marc jacobs, ugg,ugg australia,ugg italia, sac louis vuitton pas cher, canada goose, moncler outlet, pandora charms, canada goose outlet, bottes ugg, moncler, canada goose uk, replica watches, hollister, louis vuitton, louis vuitton, swarovski, moncler, swarovski crystal, links of london, ugg boots uk, moncler, louis vuitton, doudoune canada goose, ugg pas cher, coach outlet, louis vuitton, moncler, canada goose, canada goose outlet, canada goose, thomas sabo, canada goose, pandora charms, ugg,uggs,uggs canada, wedding dresses, moncler

ninest123 said...

timberland boots, soccer shoes, nike roshe, asics running shoes, oakley, juicy couture outlet, beats by dre, new balance, jimmy choo shoes, vans, north face outlet, instyler, mcm handbags, abercrombie and fitch, baseball bats, hollister, karen millen, gucci, lancel, bottega veneta, valentino shoes, louboutin, reebok shoes, north face outlet, converse outlet, hollister, herve leger, juicy couture outlet, ralph lauren, ferragamo shoes, insanity workout, ghd, nike air max, mont blanc, chi flat iron, nfl jerseys, toms shoes, supra shoes, mac cosmetics, converse, babyliss, wedding dresses, celine handbags, ray ban, vans shoes, nike air max, montre pas cher, soccer jerseys, p90x workout, birkin bag

ninest123 said...

vans pas cher, michael kors outlet, mulberry, michael kors, sac guess, new balance pas cher, ugg boots, nike air max, true religion outlet, hogan, true religion jeans, burberry, hollister, hollister, oakley pas cher, true religion jeans, coach purses, michael kors outlet, timberland, ray ban uk, converse pas cher, north face, burberry outlet online, longchamp, michael kors, nike huarache, michael kors outlet, tn pas cher, ray ban pas cher, michael kors outlet, michael kors outlet, hermes, air force, lululemon, nike blazer, lacoste pas cher, michael kors, nike trainers, ralph lauren uk, nike air max, nike roshe, nike air max, michael kors, north face, vanessa bruno, ugg boots, true religion jeans, hollister pas cher, nike free run uk, abercrombie and fitch

ninest123 said...

louboutin pas cher, nike air max, ray ban sunglasses, prada handbags, michael kors, coach outlet, coach outlet, nike free, replica watches, kate spade outlet, uggs on sale, louboutin shoes, longchamp outlet, longchamp, burberry, polo ralph lauren outlet, tory burch outlet, nike air max, louboutin, ralph lauren pas cher, louis vuitton, christian louboutin outlet, chanel handbags, prada outlet, tiffany jewelry, ray ban sunglasses, kate spade handbags, sac longchamp, nike outlet, air max, gucci outlet, air jordan pas cher, louboutin outlet, nike roshe run, replica watches, nike free, longchamp pas cher, jordan shoes, polo ralph lauren outlet, tiffany and co, cheap oakley sunglasses, ray ban sunglasses, oakley sunglasses, ugg boots, replica handbags, longchamp outlet, ugg boots

Tracert said...

Hi from the future.

Recently had to build the source for windows myself. Here is a great tutorial to follow for MVC 2017.

If you just want the package without any of the encoders/decoders use

./configure --toolchain=msvc --enable-shared --disable-opencl

To build for x264 use.

./configure --toolchain=msvc --arch=x86 --enable-yasm --enable-asm --enable-libx264 --enable-gpl

Just remember if you're going down this path when install go into (msys64) and edit the line in (msys2_shell.cmd) from:

rem set MSYS2_PATH_TYPE=inherit
set MSYS2_PATH_TYPE=inherit

Then you should good to go.