FFmpeg detailed instructions for compiling under windows

Source: Internet
Author: User

MinGW: A free-to-use and free-to-publish Windows-specific header file and a collection of import libraries using the GNC toolset, allowing you to generate local Windows programs without the need for a third-party C runtime

MinGW, minimalist GNU for Windows. It is a collection of header files and port libraries that allow people to use GCC to generate WINDOWS32 programs without a third-party dynamic-link library.

The MinGW was developed to provide a GNU-compliant GNU working environment for those who do not like to work on the Linux (FreeBSD) operating system and remain in Windows.

So, using MinGW, we can use the GNU Program development tool just like under Linux.

Minimal GNU (POSIX) system on Windows, is a small GNU environment, including basic bash,make and so on. is the best GNU environment under Windows.

---------------------------------------Build-------------------------------------------------

Thanks to the development of the software industry, it makes it easier for novices to learn and build a running environment.

Originally built Mingw+msys environment is a troublesome thing, but the new version of the MinGW direct installation can be used. Below is Wingw's Web page http://www.mingw.org/wiki/InstallationHOWTOforMinGW. Download the latest version of MinGW in the box to build the Mingw+msys environment directly.

The following minor modifications, in order to implement the FFmpeg compilation.

3) Modify "Msys.bat"
Open X:\msys\msys.bat with a text editor, because you intend to compile the program with msvc++, you need a. lib file to link to the FFmpeg library, and these. lib files can be generated using the LIB command in Microsoft's toolchain. For this reason, Microsoft's Visual Studio or Visual C + + must already be installed on the machine. Add the following line to the front of the Msys.bat and replace the path with the actual path Vcvars32.bat on the machine, such as my D:\Program Files\Microsoft Visual Studio. NET 2003\vc7\bin, So we add:
Call "D:\Program Files\Microsoft Visual Studio. NET 2003\vc7\bin\vcvars32.bat"

4) System Integration
Copy X:\msys\etc\fstab.sample to X:\msys\etc\fstab and open X:\msys\etc\fstab Edit with a text editor. (You need to use an editor that supports UNIX line-wrapping style, such as notepad++), take this line:
X:/mingw/mingw
Switch
X:/msys/mingw/mingw

Well, the environment is set up. Enter the compile ffmpeg phase.

--------------------------------------Compile--------------------------------------------------

3. Compile, get FFmpeg library (header file, lib, and DLL)

Start Msys with Msys.bat in the Msys installation directory, and a command-line window will appear, which is a RXVT program running bash, such as:

Figure 2

This is a Linux-like shell and runs on windows, like using a real Linux shell. However, use this shell to be aware of:
→ The directory name is split with a forward slash instead of the backslash used by Windows (for example, "D:/ffmpeg" rather than "D:\ffmpeg").
→ The drive letter (e.g. "C: \") can be accessed from the root directory (like this "/C/").
→ If there are spaces in the file name or directory name, you must enclose it in double quotation marks (such as "/c/program Files" with double quotes).
The following switch to the directory that holds the FFmpeg source code (if your code is D:\ffmpeg after extracting it), by typing: "Cd/d/ffmpeg".
Next, to configure FFmpeg, select the libraries that are included in the compilation, first enter:
./configure--enable-shared--disable-static--enable-memalign-hack
The--enable-memalign-hack option is required for ffmpeg to compile successfully on Windows, and after the configuration is complete, it will return to the command prompt and see the screen shown:

Figure 3

If there is no error, you can "make" has the basic function of the ffmpeg, after the prompt input: made.
The compilation process will last for a long time. If everything is OK, the end will return to the prompt and have the following output screen at the end of the final compilation:

Finally get compile-generated FFmpeg library (header file, Lib,dll)

After the prompt, enter: make install.

After execution, several files are generated under the local folder in the Msys directory. Directories such as:

4. Under VC configuration (this refers to how to call the FFmpeg library in the VC), test

VC Environment Configuration: (If the directory is shown)

Method of course, like other additional libraries, one is to set the VC global include path for you E:\msys\local\include, set the VC global Lib path to E:\msys\local\bin, increase the operating system of a path

E:\msys\local\bin. The other is to set the path of the Lib and include for a project. Add a pointer to the corresponding address above. This I do not say in detail, presumably play VC know.

First build a VC console project, and then copy the E:\FFMPEG\LIBAVCODEC\API-EXAMPLE.C (FFmpeg's storage directory) to the project you built. then renamed Api-example.cpp. Compile. You will find a header file. At this point you will need to copy the inttypes.h,stdint.h,_mingw.h three files from the E:\msys\mingw\include (include in the MinGW installation directory) to E:\msys\local\ Include (Include in the directory of your FFmpeg library). There are still many mistakes in compiling.

1. Need to #define __RESTRICT__ in Inttypes.h __restrict

2. If a long long error is changed to __int64

3. c->time_base.den= (avrational) {1,25}; Change to C->time_base.num = 1; C->time_base.den = 25;//

4. The top header file is defined as follows:

#include <math.h>//Note this, or you'll see a bug in the math template

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

extern "C"

{

#ifdef HAVE_AV_CONFIG_H

#undef Have_av_config_h

#endif

#include <libavcodec\avcodec.h>

#include <libavutil\mathematics.h>

#pragma comment (lib, "Avcodec.lib")

#pragma comment (lib, "Avutil.lib")

}

The final compilation should be no error. Because some of the test video files are not, so the code does not show any effect. Using one of the code above, just to test it, and then tell us what we need to do with the FFmpeg library we've compiled.

(Most of the above is reproduced in the space http://apps.hi.baidu.com/share/detail/20685063, thanks to his selfless dedication)

Objective

This article refers to a large amount of information on the Internet, collated, and verified by practice, the last updated March 11, 2010. In addition I use development tools for Delphi, will not VC, so there is no compilation of VC-related LIB library parts.

In this paper, the Mingw+msys environment path is assumed to be C:\MinGW and C:\MSYS, and for the Pure manual installation, that is, download the corresponding compression package, directly extracted to the corresponding directory.

This article links--http://www.codecoolie.com/ffmpeg/compile-ffmpeg-under-windows/

--codecoolie, author of this article

"Introduction" FFmpeg

http://www.ffmpeg.org

FFmpeg is a complete solution for recording, converting, and streaming audio and video, including a set of leading audio and video codec libraries called Libavcodec. FFmpeg, although developed under the Linux platform, can be compiled under most operating systems, including Windows.

MinGW

http://www.mingw.org

The compilation environment required to compile FFmpeg under Windows is MinGW, which is the minimalist GNU for Windows abbreviation. The MinGW contains the Windows platform header files, GCC, and some GNU tools.

MSYS

Http://www.mingw.org/wiki/msys

Msys is the MinGW shell environment and is the abbreviation for minimal system. Msys provides a number of development tools, such as make.

"Compilation Environment" MinGW

http://sourceforge.net/projects/mingw/files/

Download the following zip package:

GNU binutils:binutils-2.20.1-2-mingw32-bin.tar.gz
MinGW runtime:mingwrt-3.18-mingw32-dev.tar.gz
MinGW API for ms-windows:w32api-3.14-mingw32-dev.tar.gz
GCC Version 4:gcc-core-4.2.1-sjlj-2.tar.gz (gcc 4.4 has bugs, x264, XviD, and so on compile with ffmpeg when GCC crashes)

Extract the above compressed packets sequentially into the same directory, e.g. extract to C:\MinGW

Copying or renaming the following files is actually removing the SJLJ suffix:

From C:\MinGW\bin\gcc-sjlj.exe to Gcc.exe

NOTICE:LIBIBERTY.A uses the newer in the GNU Binutils package instead of the GCC core package.

MSYS

http://sourceforge.net/projects/mingw/files/

Download the following zip package:

Msyscore-1.0.11-bin.tar.gz
Msyscore-1.0.13-2-msys-1.0.13-bin.tar.lzma
Make-3.81-2-msys-1.0.11-bin.tar.lzma
Coreutils-5.97-2-msys-1.0.11-ext.tar.lzma (only needed when pr.exe,configure FFmpeg)
Vim-7.2-1-msys-1.0.11-bin.tar.lzma (not intended to use VI can not be installed)

Extract the above compressed packets sequentially into the same directory, e.g. extract to C:\MSYS

Mingw+msys

Edit the C:\MSYS\etc\fstab text, specify MinGW in the MSYS mount directory

C:/mingw/mingw

Yasm

When compiling x264, you need

http://www.tortall.net/projects/yasm/

Download: http://www.tortall.net/projects/yasm/releases/yasm-0.8.0.tar.gz

Unzip, compile and install:

./configure–prefix=/mingw
Make
Make install

"Basic Library" zlib

http://sourceforge.net/projects/mingw/files/

Download the following zip package:

MinGW zlib:libz-1.2.3-1-mingw32-dev.tar.gz

Unzip it to C:\MinGW

Delete C:\MINGW\LIB\LIBZ.DLL.A (otherwise use dynamic link, need Libz.dll)

Bzip2

http://sourceforge.net/projects/mingw/files/

Download the following zip package:

MinGW bzip2:bzip2-1.0.5-2-mingw32-dev.tar.gz

Unzip it to C:\MinGW

Delete C:\MINGW\LIB\LIBBZ2.DLL.A (otherwise use dynamic link, need Libbz-2.dll)

SDL

http://www.libsdl.org/

When compiling ffplay, you need

Download: http://www.libsdl.org/release/SDL-devel-1.2.13-mingw32.tar.gz

Unzip, modify Makefile:cross_path: =/mingw

Compile and install: make Cross

"FFmpeg Basic Compilation"

Source obtained: Svn://svn.mplayerhq.hu/ffmpeg/trunk

Configuration compilation: Assume that the installation path is/ffmpeg/release

./configure–prefix=/ffmpeg/release–enable-memalign-hack
Make
Make install

"Codec Library"

Assume that the third-party library installation path is/olibs

libgsm

GSM Support via LIBGSM

GSM 06.10 lossy speech compression

Http://user.cs.tu-berlin.de/~jutta/toast.html

Download gsm-1.0.12.tar.gz

Unzip, modify cc in makefile = gcc-ansi-pedantic to CC = GCC

Compile and install:

Make

Compile to a later error, but the library has been compiled, copy it with the following command

CP lib/libgsm.a/olibs/lib/
CP inc/gsm.h/olibs/include/gsm/

FFmpeg compilation parameters: –enable-libgsm

Libmp3lame

MP3 encoding via Libmp3lame

http://sourceforge.net/projects/lame/files/

Download lame-3.98.3.tar.gz

Unzip, modify the following line in the Lame-3.98-3/libmp3lame/i386/makefile.in

$ (ECHO) "non_pic_object= ' $*.o '" >>[email protected]

For

$ (ECHO) "non_pic_object= '. libs/$*.o '" >>[email protected]

Compile and install:

./configure–prefix=/olibs–disable-shared–enable-static–disable-frontend
Make
Make install

FFmpeg compilation parameters: –enable-libmp3lame

Opencore-amr

AMR-NB de/encoding, AMR-WB decoding via Libopencore-amrnb

http://sourceforge.net/projects/opencore-amr/

Download opencore-amr-0.1.1.tar.gz (0.1.2 compilation requires g++, LIBSTDC++.DLL.A)

Unzip and comment out several lines in the following makefile

./opencore-amr/amrnb/makefile
INSTALL:LIBOPENCORE-AMRNB.A $ (shlib)
Install-d $ (DESTDIR) $ (PREFIX)/lib
Install-m 644 LIBOPENCORE-AMRNB.A $ (DESTDIR) $ (PREFIX)/lib
# Install $ (shlib) $ (DESTDIR) $ (PREFIX)/lib
IFNEQ ($ (Shell uname), Darwin)
# LN-SF $ (shlib) $ (DESTDIR) $ (PREFIX)/lib/$ (SONAME)
# LN-SF $ (SONAME) $ (DESTDIR) $ (PREFIX)/lib/libopencore-amrnb.so
endif

./opencore-amr/amrwb/makefile
INSTALL:LIBOPENCORE-AMRWB.A $ (shlib)
Install-d $ (DESTDIR) $ (PREFIX)/lib
Install-m 644 LIBOPENCORE-AMRWB.A $ (DESTDIR) $ (PREFIX)/lib
# Install $ (shlib) $ (DESTDIR) $ (PREFIX)/lib
IFNEQ ($ (Shell uname), Darwin)
# LN-SF $ (shlib) $ (DESTDIR) $ (PREFIX)/lib/$ (SONAME)
# LN-SF $ (SONAME) $ (DESTDIR) $ (PREFIX)/lib/libopencore-amrwb.so
endif

Compile and install:

Make CC=GCC
Make install Prefix=/olibs

FFmpeg compilation parameters: –ENABLE-VERSION3–ENABLE-LIBOPENCORE-AMRNB–ENABLE-LIBOPENCORE-AMRWB

Libogg

For Libvorbis and Libtheora

http://www.xiph.org/downloads/

Download libogg-1.1.4.tar.gz

Unzip, compile and install:

./configure–prefix=/olibs–disable-shared
Make
Make install

Libvorbis

Vorbis encoding via Libvorbis

http://www.xiph.org/downloads/

Download libvorbis-1.2.3.tar.gz

Unzip, compile and install:

./configure–prefix=/olibs–disable-shared–with-ogg=/olibs
Make
Make install

FFmpeg compilation parameters: –enable-libvorbis

Libtheora

Theora encoding via Libtheora

http://www.xiph.org/downloads/

Download Libtheora-1.1.1.zip

Unzip, compile and install:

./configure–prefix=/olibs–disable-shared–with-ogg=/olibs
Make
Make install

FFmpeg compilation parameters: –enable-libtheora

libx264

H. Encoding via x264

Http://www.videolan.org/developers/x264.html

ftp://ftp.videolan.org/pub/videolan/x264/snapshots/

Download the latest source package

Unzip, compile and install:

./configure–prefix=/olibs
Make
Make install

FFmpeg compilation parameters: –enable-gpl–enable-libx264

Libxvid

Xvid encoding via Xvidcore

http://www.xvid.org/

Download xvidcore-1.2.2.tar.gz

Unzip, modify:

./build/generic/configure: "Libxvidcore. <-"Xvidcore.

Compile and install:

CD Xvidcore/build/generic
./configure–prefix=/olibs–disable-shared
Make
Make install

Delete/olibs/lib/libxvidcore.dll

FFmpeg compilation parameters: –enable-gpl–enable-libxvid

LIBFAAC, Libfaad

FFmpeg built-in has support AAC encoding, decoding, do not need LIBFAAC, Libfaad, and Libfaac is nonfree, nonfree is unredistributable is forbidden to publish

"FFmpeg Advanced Compilation"

Assuming the installation path is/ffmpeg/release, assume that the third party libraries Path is/olibs

Configuration compilation:

./configure \
–prefix=/ffmpeg/release \
–disable-debug \
–disable-static \
–enable-shared \
–ENABLE-GPL \
–enable-version3 \
–enable-avfilter \
–ENABLE-AVFILTER-LAVF \
–enable-memalign-hack \
–enable-avisynth \
–ENABLE-LIBGSM \
–enable-libmp3lame \
–ENABLE-LIBOPENCORE-AMRNB \
–ENABLE-LIBOPENCORE-AMRWB \
–enable-libtheora \
–enable-libvorbis \
–enable-libx264 \
–enable-libxvid \
–extra-cflags=-i/olibs/include \
–extra-ldflags=-l/olibs/lib
Make
Make install

FFmpeg detailed instructions for compiling 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.