Detailed steps for compiling the FFmpeg project under Windows

Source: Internet
Author: User

This article from: http://www.cuplayer.com/player/PlayerCode/FFmpeg/2014/0706/1401.html

The detailed steps for compiling the FFmpeg project under Windows are described in the text:

1. Build MinGW Environment

Download yasm, Address: http://yasm.tortall.net/Download.html

Rename the Yasm.exe to the C:\WINDOWS\system32 or C:\MinGW\msys\1.0\bin folder.

Download Mingw-get-inst-20101030.exe, click here to download http://sourceforge.net/projects/mingw/files/.

Select the following when installing

Networking is required during the installation process. The installer will go online to download the corresponding program. This process takes a long time, please wait patiently.

Note: If the network disconnects or fails to download some of the builds during the installation, do not worry, wait for the setup program to run and then run Setup again, select as above, the installer will continue to download the software without success.

Open the C:\MinGW\msys\1.0\msys.bat file and add the file header

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

The function of this sentence is: Set the development environment of x86. We mostly use its lib.exe to generate *.lib files.

Running Msys.bat, the program will build a working directory under the directory (C:\MinGW\msys\1.0\home) based on your current user name.

The name of the directory is the same as your user name. If the current user name of your system is administer, then your working directory is (C:\MinGW\msys\1.0\home\administer)

2. Compiling FFmpeg

Unzip the FFmpeg code into the MinGW working directory. For example (C:\MinGW\msys\1.0\home\administer)

Running C:\MinGW\msys\1.0\msys.bat, you can enter the MinGW working directory.

He and cmd command difference, right slash need to change to left slash, drive letter D: Also change to/d

Enter the command "LS", which is equivalent to "dir". Lists the files in the current directory.

Enter the CD ffmpeg and enter the FFmpeg directory.

Enter the following command at the command line:

./configure--enable-memalign-hack--enable-shared make make and install

After success, the compiled generated file is saved in (C:\MinGW\msys\1.0\local\bin), and the header file is saved in (C:\MinGW\msys\1.0\local\include).

./configure--disable-debug--enable-static--enable-memalign-hack--enable-swscale--disable-avformat-- Disable-avfilter--enable-pthreads--enable-runtime-cpudetect--disable-w32threads--disable-ffprobe-- Enable-version3--disable-everything--enable-decoder=h264--enable-decoder=mpeg4--disable-ffmpeg--enable-parser= H264--enable-parser=mpeg4video--enable-parser=mpegvideo

3. Use ffmpeg static library in VC
Additional Dependencies

LIBAVCODEC.A libavformat.a libavutil.a libswscale.a libz.a libdts.a libfaac.a libfaad.a

LIBGSM.A libmp3lame.a libnut.a libogg.a libtheora.a libvorbis.a libvorbisenc.a libx264.a

Libxvidcore.a libpthreadgc2.a libgcc.a libmingwex.a wsock32.lib vfw32.lib

To use FFmpeg's static library, you must also link other static libraries used by FFmpeg to the project of the VC. These libraries mainly include

LIBGCC.A:GCC's library of functions, generally in C:\MinGW\lib\gcc\mingw32\4.x.x\

Libmingwex.a:_snprint function, generally in C:\MinGW\lib\

The realization of libcoldname.a:_strcasecmp, also in C:\MinGW\lib\

Wsock32.lib:Windows Socket Library

Libz.a:zip Compression Library

Additional codec libraries such as Libfaad, libx264, etc.

The link order of the static library must not be wrong, or there will be some inexplicable problems when running. The suggested link order is

LIBGCC.A libmingwex.a libcoldname.a libavcodec.a libavformat.a

LIBAVUTIL.A libswscale.a libz.a libdts.a libfaac.a libfaad.a LIBGSM.A

Libmp3lame.a libnut.a libogg.a libtheora.a libvorbis.a libvorbisenc.a

libx264.a libxvidcore.a libpthreadgc2.a wsock32.lib vfw32.lib

Compiling ffmpeg

There are two compile methods, one is a static library, and the other is a dynamic library.

Start Msys First,

C:/msys/1.0/msys.bat

The prompt on the shell is as follows:

[email protected] ~$ first into the FFmpeg directory, the compilation is generally three steps, first configure, then compile, and finally install. If you change the way you compile, clean the configuration before you configure it

3.1 Compiling a static library

A. Configuration

At the shell prompt, enter:

./configure--enable-static--enable-memalign-hack--prefix=c:/msys/1.0--extra-cflags= "-fno-common"

This process takes a long time and begins to be unresponsive for a longer period of time. Where prefix is the installation path of Msys

B. Compiling

Make

C. Installation

Make install

The installation simply copies the library files to be developed for use in the c:/msys/1.0/lib/directory, and the header files are copied to the c:/msys/1.0/include/directory.

The resulting library file is a. a file

3.2 Compiling the dynamic library

The dynamic and static libraries differ only in configuration, and are configured as follows:

./configure--enable-shared--disable-static--enable-memalign-hack--prefix=c:/msys/1.0--extra-cflags= "- Fno-common "

Follow the same steps:

Make

Make install

Before you start compiling, you can erase the original compiled target file:

Make Distclean

Dynamic compilation should be generated lib file, but I have not generated after compiling, so the subsequent development, with the static library

The compiled DLL files are placed in the FFmpeg directory and can be searched to view them

4. Development

Based on the development of FFmpeg, originally was thinking relatively simple, but actually still a bit of a problem

At first compiled under the vc6.0, has been compiled however, had to put into vs2008 under the compilation, only compiled through, but in the release still can't compile through, link error as follows:

1>LIBMINGWEX.A (MBRTOWC.O): Error LNK2019:
unresolved external symbol __imp____lc_codepage referenced in function _mbrlen
1>LIBMINGWEX.A (WCRTOMB.O):
Error lnk2001:unresolved external symbol __imp____lc_codepage1>
.. /binrelease/chipdecoder.dll:fatal Error lnk1120:1 unresolved externals

The header and library files that are included are as follows:

#ifdef __cplusplusextern "C" {#endif

#include "Libavformat/avformat.h"

#pragma comment (lib, "LIBGCC.A")
#pragma comment (lib, "LIBAVCODEC.A")
#pragma comment (lib, "Libavformat.a")
#pragma comment (lib, "Libavutil.a")
#pragma comment (lib, "Libmingwex.a")
#ifdef __cplusplus} #endif其中的libgcc. A and libmingwex.a are copied from C:/msys, before compiling c:/msys/1.0/include and c:/msys/1.0/ LIB two directories added to the compilation project

In addition, because I was compiled under the vc6.0, unable to compile the pass, so the header files are partially modified:

A. Copy the three files under c:/msys/1.0 _mingw.h, Inttypes.h, stdint.h to the Include directory

B. Add a line at the end of the _mingw.h file (before the #endif/* __mingw_h */Line):

#define __restrict__

C. Change all long long to __int64, if it is compiled directly under VS2008, then this modification should not be required.

D. In the StdAfx.h file

#include <windows.h>

After that, add:

#include <math.h>

Note that this line must be avformat.h before it is included, otherwise it will always be compiled in MATH.H

Detailed steps for compiling the FFmpeg project under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.