Friday, February 19, 2010

Building ffplay for windows

For Building ffplay we need SDL-devel installed.

Go to libsdl.org, and near the end, at Development Libraries, get the latest under Win32, for MinGW32, not Visual C++.

you can download drectly from here
download




Unpack the file.

just unpacked downloaded files
Copy all the files from the lib folder to C:\msys\mingw\lib\.
Copy the SDL folder from the include folder to C:\msys\mingw\include\.
Copy all the files from the bin folder to C:\msys\mingw\bin\.


Edit c:\msys\mingw\bin\sdl-config with an editor that understands Unix line endings (like wordpad.exe).
Change the line that says:
prefix=/Users/hercules/tmp/SDL-1.2.13
to
prefix=/mingw
The SDL.dll file must be in the PATH for ffplay.exe to run correctly.
The bin folder it was copied to, is in the PATH for MSys.
But if you want to run ffplay.exe from outside of MSys, you'll have to copy SDL.dll.
Now, whenever you run ./configure --enable-static --enable-shared --enable-memalign-hack for FFmpeg, it should find SDL and build FFplay correctly.

Thursday, February 11, 2010

Compile ffmpeg for windows and using dll's with vs2008 vc++

Steps For Creating ffmpeg Dll's for windows and using vs2008
List of requirements for compiling on windows.
1)msys
2)mingw
3)Latest ffmpeg code from svn
Installing msys:
First of all we will download all packages which we will require Please Download all Packages Listed below
1) Create a folder name mingw here we are going to download all packages required for mingw.
Please download
download #binutils-2.19.1-mingw32-bin.tar.gz
download #mingwrt3.15.2mingw32-dll.tar.gz
download #mingwrt3.15.2mingw32-dev.tar.gz
download #w32api-3.13-mingw32-dev.tar.gz
download #gcc-core-4.2.1-sjlj-2.tar.gz
download #gcc-g++-4.2.1-sjlj-2.tar.gz

For installing msys you need these two packages you can install below
downloadMSYS-1.0.11.exe
coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
Installing MSYS_exe

* Run MSYS-1.0.11.exe.

* Click Yes.

* Click Next >.

* Click Yes if you agree with the license.

If you don't agree with the license what are you doing trying to use open source software? =)

* Click Next >.

Choose where you want to install MSys. It defaults to C:\msys\1.0, but I prefer setting the install path to C:\msys.

* Set it to C:\msys. Click Next >.

* Click Next >.

Choose where you want MSys to be located in the Start Menu. It defaults to MinGW, but I prefer setting it to msys.

* Set it to msys. Click Next >.

Click Install.

After a while, you'll get a screen asking:

This is a post install process that will try to normalize between
your MinGW install if any as well as your previous MSYS installs
if any. I don't have any traps as aborts will not hurt anything.
Do you wish to continue with the post install? [yn ]

Type y and press Enter.

Donot Close Running Setup just extract mingw packages which we downloaded in starting in the folder c:\msys\mingw
binutils-2.19.1-mingw32-bin.tar.gz
mingwrt3.15.2mingw32-dll.tar.gz
mingwrt3.15.2mingw32-dev.tar.gz
w32api-3.13-mingw32-dev.tar.gz
gcc-core-4.2.1-sjlj-2.tar.gz
gcc-g++-4.2.1-sjlj-2.tar.gz
Extract all packages listed above in C:\msys\mingw
Now
go to C:\msys\mingw\bin\ and rename:
c++-sjlj.exe to c++.exe
cpp-sjlj.exe to cpp.exe
g++-sjlj.exe to g++.exe
gcc-sjlj.exe to gcc.exe
Now its completed with mingw
Continue with msys Installation

Continue
Do you have MinGW installed? [yn ]

Type y and press Enter. You'll get:

Please answer the following in the form of c:/foo/bar.
Where is your MinGW installation?

Type c:/mingw and press Enter. If there are any errors you'll get this screen:

I could not find /bin/gcc.exe. You must have given an invalid
path to your MinGW environment. I am reversing to no MinGW
installation. If you do have MinGW installed then you can manually
bind the mount point /mingw to C:/mingw (replace C: with the
drive of your choice) by creating an /etc/fstab file with a line
that has a value similar to:
C:/mingw /mingw
Press ENTER to continue

This may be because you misspelled the path, or because you haven't installed gcc yet, or because you forgot to rename gcc-sjlj.exe to gcc for the official 4.2.1 release. If you got that screen, then we'll worry about it in a while. Just keep pressing Enter until the command prompt closes.

Anyways, if you got the path right, you'll get:

Creating /etc/fstab with mingw mount bindings.
Normalizing your MSYS environment.

You have script /bin/awk
You have script /bin/cmd
You have script /bin/echo
You have script /bin/egrep
You have script /bin/fgrep
You have script /bin/printf
You have script /bin/pwd

Oh joy, you do not have c:/mingw/bin/make.exe. Keep it that way.

C:\msys\postinstall>pause
Press any key to continue . . .

Press Enter again.

Uncheck both boxes and click Finish.


If you did get the error about wrong gcc path and you confirmed that gcc is now installed and in the correct path (c:\mingw), then go to c:\msys\etc and copy the file fstab.sample to fstab.


Installing coreutils

Unpack the file. Copy coreutils-5.97\bin\pr.exe to C:\msys\bin\.

Other utils from that package might be welcome too (like du and kill) but aren't necessary for compiling and running FFmpeg.



Updating msys for MSVC

If you plan on compiling your apps with MSVC++ (note: your apps, not FFmpeg), and linking them against FFmpeg DLLs, you will need to generate .lib files for the shared libraries. Note this is not needed if you plan on linking against static FFmpeg libraries. Those .lib files can be generated by the lib command from Microsoft's Toolchain. For that, you must have Microsoft Visual Studio, or Microsoft Visual C++.

Open C:\msys\msys.bat in a plain-text editor, such as notepad.exe. Add the following line to the beggining of msys.bat, replacing the path leading to vcvars32.bat to wherever that file is located in your computer (note: you must use quotation marks if there are any spaces in the path):

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

Now it is finished with msys and mingw setup now we will take latest code of ffmpeg from svn and build it.
FFmpeg source code resides in an SVN repository, you must be able to access those files either by a command-line program, or by a graphical user interface front-end.
Download Tortise SVN 32 bit windows From Here
Download Tortise SVN 64 bit windows From Here
After getting tortise svn installed on your system check out ffmpeg repository
create a folder inside msys name ffmpeg.
right click on that folder and click on SVN CheckOut
On URL of repository:, write:

svn://svn.mplayerhq.hu/ffmpeg/trunk

On Checkout directory:, write the path to where you want FFmpeg to be downloaded to. Such as:

C:\msys\ffmpeg

Click OK.


After that Latest ffmpeg code will start download in the C:\msys\ffmpeg folder



Building ffmpeg dll's for windows

On the Start Menu, go

Start->Programs->MSys->MSYS->MSYS

A command prompt will open, and you should see this screen:

go ffmpeg folder in my case it is in c:\msys\ffmpeg.if the same in your case then
cd ..
and cd..
now
cd ffmpeg



now run the command
./configure --enable-static --enable-shared --enable-memalign-hack
and press enter
The --enable-memalign-hack option is necessary for FFmpeg to run MMX and SSE-optimized code on Windows.

After a while, when it finishes configuring, a bunch of lists will print out and it will go back to the prompt. You should see something like this:

If there are no errors, you're all set to make FFmpeg. Enter this in the prompt:

$ make

If you have multiple CPUs or multiple cores in your CPU, you may try building FFmpeg with more than one process at the same time. This speeds up compilation considerably. For that, give make a -j parameter followed by the number of processes you want to run at the same time. For example, in a dual-core machine:

$ make -j2

This will take long. It is the actual compiling of the complete FFmpeg source code. If all goes well, once it's done, you'll be back in the prompt with this output:

The program is already compiled. You can find the ffmpeg.exe executable on the build folder. After that, all you have to do is install the program, with the command:

make install

FFmpeg will install to a default folder (/usr/local) if you have not provided a specific --prefix option in configure. Remember that /usr/local can be found right under MSYS's folder. In Windows paths, if you followed this wiki correctly, that would be C:\msys\local (in MSYS, the /usr folder is a link to /).


Three folders will be installed:
bin contains the ffmpeg.exe executable. This is what you want. It runs standalone.
include and lib contain the include and lib files to be used when writing a program that uses FFmpeg. If you just want to run FFmpeg, all you need is ffmpeg.exe.


Good. Now you can just run ffmpeg.exe exactly the way you wanted in the first place. You're all set. FFmpeg was successfully statically compiled and installed.