2009年8月22日星期六

Compile and Build FFMPEG on Windows Platform

整个安装是首先安装MinGW,然后安装MSys。

其中,需要coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2

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

然后

./configure --enable-memalign-hack最后make

和make install.

If you followed Building FFmpeg SVN statically correctly, you should already have static libraries built.

After you make install, they will be installed in /lib, and will be called libav*.a.

Yes, those libraries can be used by MSVC++. Think of them being the same thing as the .lib files MSVC++ generates.


参考网站:http://ffmpeg.arrozcru.org/wiki/index.php?title=MSys_MinGW

到此为止。

以下为开始收集到的一些资料:


Installing FFMPEG from the source in window platform is easy as you do for other window application. Here is the complete instructios how to build FFMPEG in windows. To install FFMPEG on windows you need to install third party MinGW and MSys library that is compatible with GCC. This library is required to build ffmpeg in windows and support shell to run commands.

Download MinGW and MSys

MinGW: MinGW Direct download link
MSys: MSys Direct download link
SF Link: Sourceforge MinGW MSys Package Download Page
FFMPEG: FFMPEG Download fully patched version

ffmpeg mingw msys compile build

Building FFMPEG

It is time to install ffmpeg. Extract downloaded ffmpeg archive in c: folder. If you have not downloaded yet please download now then run MSys.bat file from C:\msys\1.0\ folder. This location will be depend on you MinGW and MSys installation. In the command prompt run the following commands:


$ cd c:/ffmpeg-0.4.7

$ ./configure –extra-cflags=”-mno-cygwin -mms-bitfields” –extra-ldflags=”-Wl,–add-stdcall-alias” –enable-mingw32 –enable-shared –disable-a52 –disable-pp –disable-ffserver –disable-ffplay
$ make



This tutorial is about transcoding video fom one codec into another using FFMPEG. I got deeper into FFMPEG when I wanted to transcode into FLV (Flash Video) and it works very well. I developed the Riva FLV Encoder, a GUI for FFMPEG.

Update 26.10.2006: This tutorial is a little outdated as there were many changes in FFMPEG like the switch from CVS to Subversion and the workflow to compile FFMPEG under Windows has become more difficult. For the new tweaks check this tutorial.

  1. Download MinGW ” MSYS current releases (Window Exe Binaries MSYS-1.0.10.exe & MinGW-3.1.0-1.exe)
      Install MinGW
      Install MSYS
      HINT: During the Postinstall be sure to set the right path to MinGW with a “/” instead of a Windows-”". If you did it wrong anyway re-install MSYS to the same directory and do the postinstall right (I missed it a few times)
  2. Download and compile Lame
      Extract Lame to your MSYS home-directory
      Open MSYS and change to your lame-directory (cd ../lame-XXX)
      Enter the following commands:
      ./configure //(takes a few minutes) make //(lame is being comiled; takes a few minutes, too) make install
      After installing you will recognize that there are new directories and files in MSYS/local which we will use while compiling ffmpeg with mp3-support
  3. Download Subversion Client like Tortoise SVN (http://http://tortoisesvn.tigris.org/) and install it
      Check out the sourcecode from svn://svn.mplayerhq.hu/ffmpeg
    • Compile FFMPEG
        Change the directory in MSYS to your ffmpeg-directory (cd ../ffmpeg)
        Enter the command:
        ./configure --enable-memalign-hack --enable-mingw32 --enable-mp3lame --extra-cflags=-I/local/include --extra-ldflags=-L/local/lib
        HINT: you can paste into MSYS by pressing your center mouse-button
      1. “–enabled-memalign-hack” is a Windows hack. Without this option ffmpeg always crashs with the message “removing common factors from framerate” when encoding AVIs.
      2. “–enable-mingw32″. I see no difference without it but we compile with MinGW and it would not do a harm when ffmpeg knows this
      3. “–enable-mp3lame”: Enable transcoding audio with the open-source mp3-lame-codec
      4. “–extra-cflags=-I/local/include –extra-ldflags=-L/local/lib”: The cflags- and ldflags-parameter sets the right path to your lame-installation which you did in step 3.d.
        Enter command: make (ffmpeg is being compiled; takes a few minutes)
        With “make install” you could now copy the ffmpeg.exe to c:Program Filesffmpeg. But there is no need to.
    • Use FFMPEG
        Copy your compiled ffmpeg.exe from your MSYS directory to the directory where you like to transcode with ffmpeg
        Open the Dos-Shell and change to the directory where you copied the ffmpeg.exe
        Copy a test.mpg into your directory and enter the following command:
        ffmpeg -i test.mpg -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
        Your first FLV should be encoded now
    • Render Images from a Video
        Enter command:
        ffmpeg -an -y -t 0:0:0.001 -i test.flv -f image2 test%d.jpg
      • HINT: With -t you set the length of images to be extracted. Above we entered 1 millisecond the extract one image. If you miss this parameter all images of the video will be extracted



    Compiling FFMpeg

    FFmpeg is developed under Linux, but it can be compiled under most operating systems.

    For Windows, FFMpeg can be compilied by MSYS and MingGW. If you had setup MSYS and MingGW system correctly, you can compile FFMpeg under it's folder.

    1. Cleanup former build results.

    Collapse
    make distclean 

    2. Setup build parameters.

    Collapse
    ./configure --enable-shared --disable-static --enable-memalign-hack 

    If there are no errors, and config.mak and config.h generated, you can build the library, and then, if you want, you can install them into MSYS environment.

    Collapse
    make 
    make install 

    Using FFMpeg in Your Visual C++ Environment

    1. Create inttypes.h and stdint.h if you don't have them. Attachment is a copy of these two files. You can get them from other place if you want.

    2. Setting up Additional Include Directories and Additional Library Directories. By default, these folder is under your MSYS folder, for example:

    Collapse
    /usr/local/include
    /usr/local/lib 

    3. Add FFmpeg's shared libraries, include libavutil.lib libavcodec.lib libavformat.lib:

    4. Include the FFMpeg header,

    Collapse code snippet
    #include <ffmpeg/avformat.h> 
    #include <ffmpeg/avcodec.h>  

    Using the FFMpeg code

    There are an example within FFMpeg, output_example.c. But if you copied codes from this example, following tips may ensure you compiles successfully.

    1. Add required casts.

    2. Change snprintf to _snprintf

      没有评论:

      发表评论