I. Preface
FFmpeg is an open source project based on Linux development, and its source code is incompatible with the C + + compiler provided by the most common Visual Studio under Windows, so it does not support msvc++ compilation. You need to configure a Linux-like compilation environment under Windows to compile.
Compiling the dynamic-link library DLLs will make no difference in usage as with other dynamic-link libraries. You can use msvc++ to link these libraries to other programs, in other words, software development under the Windows + Visual studio platform.
If you do not have time to understand the following compilation process, you can download the following link directly: The package contains the compiled FFmpeg library and the executable file, and supports the H + + codec:
http://download.csdn.net/detail/liyuefeilong/9289455
Note: Compile and configure ffmpeg according to your own requirements, if you want the compiled ffmpeg to support the codec of MP3 format, you need to download mp3lame; to make the compiled FFmpeg support encoding and decoding of XviD format, you need to download XviD ... More requirements can be found in article: http://blog.chinaunix.net/uid-20718335-id-2980793.html
Two. Preparatory work
First you need to prepare the software tools and source code needed for the compilation process:
1.mingw+msys: A free-to-use and free-to-publish Windows-specific header file and a collection of imported libraries using the GNU toolset can be configured to let FFmpeg compile with the Windows downgrade DLL corresponding to lib. To simplify the cumbersome configuration process, download the Mingw-msys bundle software directly, follow the software's default Setup wizard to install the program and configure the installation path, and you will soon be ready to install the software.
Download Link: http://sourceforge.net/projects/mingwbundle/
2.Yasm: Compile the assembler code required for ffmpeg inside the compiler.
Download Link: http://yasm.tortall.net/releases/Release1.3.0.html
3.SDL (Simple DirectMedia Layer): is a set of open source cross-platform multimedia Development Library, if you need to use Ffplay, you must compile and configure the SDL before compiling ffmpeg, otherwise you cannot generate Ffplay, However, after the native attempt to configure the SDL and complete the compilation of FFmpeg, the generated Ffmpeg.exe, Ffplay.exe, and Ffprobe.exe will not be able to output the information properly at runtime, as the internet says.
Download Link: http://www.libsdl.org/download-2.0.php
4.x264: In order for the compiled ffmpeg to support the codec of the x264 format, the x264 package needs to be downloaded first.
Download Link: http://www.videolan.org/developers/x264.html
5.FFmpeg: Directly download the source code, I use the version is ffmpeg-2.8.2. FFmpeg is available in a wide variety of distributions and can be found at the links below.
Download Link: http://ffmpeg.org/download.html
All of the above software tools can be downloaded directly from the following links: Each tool is not necessarily the latest version, if you need to use the latest version, please download the software and source code yourself.
Three. Compilation process
1.mingw+msys Installation
The installation process for the Mingw-msys bundle software is simple, just follow the default Setup Wizard setup and configure the installation path, and the installation path I choose is: C:\MinGW and C:\msys\1.0.
After the installation is complete, you need to configure Msys.bat to launch a terminal similar to the Linux environment. (After the installation is complete, my msys.bat path is: C:\Program files (x86) \mingw-msys), then open the file in edit mode and add the following command on the first line (after @echo off), where the path depends on the visual Installation path for studio:
Call "C:/Program Files (x86)/microsoft Visual Studio 11.0/vc/bin/vcvars32.bat"
2.YASM
Download yasm exe file on http://yasm.tortall.net/Download.html (Win32.exe also Win64.exe depending on your operating system), rename it to Yasm.exe after downloading, and place it in the bin directory of the MinGW installation directory.
If you do not perform this step, you may be prompted to not find the YASM command during the subsequent compilation of FFmpeg. This is due to the ffmpeg inside the assembly acceleration part of the code needs to use it, if the assembly acceleration is disabled, the compiled codec library will affect the efficiency of the operation.
3.x264 compiling
FFmpeg itself only supports the decoding of H. C Video, so if you need to use the encoding, you need to download the x264 source package to compile, according to the above mentioned link to download the file last_x264.tar.bz2, and then press to: C:\FFmpeg\ directory, and then, run Program Files (x86) \mingw-msys to start MinGW32, use the following instructions to switch the work path to the x264 directory: C:\FFmpeg\ x264-snapshot-20151119-2245
cdcdcd x264-snapshot-20151119-2245
After entering the directory, execute the following command in turn:
$ ./configure --enable-shared --disable-asm$ make$ make install
If the operation is correct, the result is as follows:
The results of the compilation can be found in the: C:\MinGW\msys\1.0\local directory.
4. Copy the compilation results of H.
For subsequent compilations, the contents of the bin are copied to the bin from C:\msys\1.0\local to D:\MinGW, and the same include is copied to the include; Lib is copied to Lib. Of course, the copy process you can not do, as long as the compile time to refer to the path to C:\msys\1.0\local inside.
5. Compiling ffmpeg
Use the Configure command to configure the compilation parameters of the FFmpeg, depending on the required components, the input instructions will be different, or you can disable some features using directives. My configuration parameters are as follows:
.--enable-shared--enable-gpl –enable-libx264 –enable-static
Without a problem, the config file is generated, as shown in.
The final step is to enter make for compiling, which will take a while. When the compilation is complete, enter make install to deploy.
The compile step completes and the resulting file is in the path: C:\msys\1.0\local directory. The generated dynamic library is in the following: C:\msys\1.0\local\bin directory; the link library file is in the: C:\msys\1.0\local\lib directory. Where the suffix is . DLL.A is the link file required for the dynamic library,. A is a pure static library (not dependent on DLLs); Modifying the extension to. lib is available. The required header files are in the path: C:\msys\1.0\local directory.
When you run Ffmpeg.exe or Ffprobe.exe, you may be unable to start the program error, because the computer lost information such as PthreadGC2.dll and Libiconv-2.dll, only need to find the corresponding DLL under C:\MinGW\bin. Copy to the current directory, or put it in the system directory C:\WINDOWS\system32 (64-bit system: C:\WINDOWS\SYSWOW64). Here are the following when running Ffmpeg.exe:
Four. Reference links
Http://blog.sina.com.cn/s/blog_513f4e8401011yuq.html
Http://www.cnblogs.com/lidabo/p/3967473.html
http://blog.csdn.net/finewind/article/details/38854517
Compilation and configuration of open source codec library under Windows system and FFmpeg-2.8.2