Use mingw + msys to compile FFMPEG in Windows

Source: Internet
Author: User
Tags ultraedit

This article has referenced many articles on the Internet, but it does not directly guide compilation due to version environment issues. This article draws on the experience of many Parties and writes it on the basis of multiple compilation experiments, reprinted. Please note the source.
FFmpeg is developed on the Linux platform, but it can also be compiled and run in other operating system environments. This article describes how to compile FFMPEG in windows.
1. Compilation preparation
You 'd better create a directory to save the following files.
1. Download mingw and msys
Mingw (minimalist GNU on Windows): a Windows-specific header file that can be freely used and released, and a collection of imported files using the GNU tool set, allows you to generate local Windows programs without a third-party C Runtime Library.
To: http://sourceforge.net/projects/mingw/ to download
A click "Download mingw-get-inst-...exe"
B. Switch to the page: Download? Check your browser's security bar, or try a direct link, or try another mirror.
C Click "direct link" to download files similar to: mingw-get-inst-20111118.exe
Tip: The msysjob will be downloaded again later. mingw-get-inst-20111118.exe already contains msys1.0, which will be displayed later during installation.
2. Download yasm (assembly compiler)
Compilation code when ffmpegediting is complete; yasm.exe
Go to the official website: http://yasm.tortall.net/Download.html download
In the latest release column, download Win32. EXE (for general use on 32-bit windows)
File Name is similar to: yasm-1.2.0-win32.exe
3 download FFMPEG
FFmpeg is available in http://www.ffmpeg.org/releases/
Download the latest version, such as the ffmpeg-0.8.6.tar.gz.
File Name is similar to: ffmpeg-0.8.6.tar.gz
Of course, you also use the method introduced on the Internet to directly download source code using SVN.
SVN: // SVN. mplayerhq. hu/FFMPEG/trunk
4. Download mp3lame (MP3 supported, optional)
To enable the compiled FFMPEG to support encoding/Decoding in MP3 format, you need to download lame first.
Up to: http://sourceforge.net/projects/lame/files/ download
The file name is similar to: lame-3.99.2.tar.gz package.
5. Download x264 (optional)
To enable compiled FFMPEG to support x264 encoding/decoding, You need to download x264 first.
To: http://www.videolan.org/javass/x264.htmldownload
The file name is similar to the package of last_x264.tar.bz2.
6. Download Xvid (Xvid is supported and optional)
To enable the compiled FFMPEG to support the encoding/Decoding of XviD format, you need to download Xvid first.
To: http://www.xvid.org/download
The file name is similar to: xvidcore-1.3.2.tar.gz package.
7. Download faad2 (faad supported, optional)
To: http://www.audiocoding.com/downloads.html download: version 2.7 bootstrapped tar. GZ package
The file name is similar to: faad2-2.7.tar.gz package.
8 download faac (faac supported, optional)
To: http://www.audiocoding.com/downloads.html download: Version 1.28 bootstrapped tar. GZ package
The file name is similar to: faac-1.28.tar.gz package.
9 download aacenc (supports AAC and optional)
To: http://sourceforge.net/projects/opencore-amr/files/ downloading: Vo-aacenc
The file name is similar to: vo-aacenc-0.1.1.tar.gz package.
10 download Amr-Nb and Amr-WB (early FFMPEG supports 3GP, optional)
To: http://www.penguin.cz/%7Eutx/amr download: amrnb-7.0.0.2.tar.bz2and amrwb-7.0.0.4.tar.bz2
The file name is similar to the package of the amrnb-7.0.0.2.tar.tar and amrwb-7.0.0.4.tar.tar.
11 download opencore-AMR and Vo-amrwbenc (support for 3GP, optional)
To: http://sourceforge.net/projects/opencore-amr/files/ download: opencore-AMR and Vo-amrwbenc
The file name is similar to the package of the opencore-amr-0.1.2.tar.gz and vo-amrwbenc-0.1.1.tar.gz.
12 download SDL (support for SDL, optional)
SDL download can go to: http://www.libsdl.org/download-1.2.php
In the source code bar, select SDL-1.2.14.tar.gz-GPG signed for download,
The file name is similar to: SDL-1.2.14.tar.tar, which requires compilation to generate the Lib library.
You can also directly download the SDL-devel-1.2.14-mingw32.tar.gz (mingw32), the file name is similar to: SDL-devel-1.2.14-mingw32.tar.tar, this file with compiled Lib, can be used directly when compiling FFMPEG.
13 download pthreadgc2.dll
Pthreadgc2.dll is a powerful DLL file for processing digital video editing software premiere6. This is a non-threatening file. Files belonging to the open source software Community project.
Go to Baidu.com and search for the download.
Step 2
1. Install mingw and msys
Run the download file: mingw-get-inst-20111118.exe,
Select "Download latest repository catalogues" in step 1"
Select the installation path: C: \ mingw (I directly use the default path without modification)
In the select components step, select:
√ C compiler (selected by default)
√ C ++ Compiler
√ Msys Basic System (msys will be installed if this option is selected, and msys does not need to be installed separately)
√ Mingw developer Toolkit
Wait until installation is complete! (You need to wait for a certain amount of time, because the file needs to be downloaded during the installation process. The faster the network speed, the faster the installation)
After the installation is complete, you can see the msys folder in the C: \ mingw directory, and msys has been installed.
2. Configure the msys. bat batch file
To facilitate vs200x and vs2010 to call the FFMPEG dynamic library, you can configure FFMPEG to generate the Lib corresponding to DLL calls in windows during compilation. Of course, if you do not need this, you can skip the following steps and go to step 3.
Go to the C: \ mingw \ msys \ 1.0 \ folder, use ultraedit to open the msys. BAT file, and add the following line at the beginning of the file:
Call "D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ bin \ vcvars32.bat"
The effect is as follows:
Call "D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ bin \ vcvars32.bat"
@ Echo off
Rem copyright (c): 2001,200 2, 2003,200 4, 2005 earnie Boyd
Rem mailto: earnie@users.sf.net
Rem this file is part of minimal System
Rem http://www.mingw.org/msys.shtml.
Rem
Rem file: msys. bat
Rem revision 2.4
Rem revision date: December 8th, 2005
Rem ember to set the "Start in:" Field of the specified cut.
Rem a value similar to C: \ msys \ 1.0 \ bin is what the "Start in:" field needs
Rem to represent.
Among them, "d: \ Program Files \ Microsoft Visual Studio 10.0" installs vs200x or vs2010 directories on your machine. My computer installs vs2010 and is installed on the D Drive. Save the modified file.
3. System Integration
Use ultraedit to modify the fstab file under the c: \ mingw \ msys \ 1.0 \ etc directory. If fstab does not exist, copy the fstab file. change the name of sample to fstab, and change the content to C:/mingw, that is, the installation path of mingw.
4. Configure yasm
To reduce the trouble of configuring environment variables, you can directly change the yasm-1.1.0-win32.exe file name to: yasm.exe and put it in the system directory: c: \ windows \ system32.
5 compile mp3lame (optional)
Lame-3.99.2.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat, start mingw32, and switch to the lame Directory: D: \ FFMPEG \ lame-3.99.2
$ CD/d
$ CD FFMPEG
$ CD lame-3.99.2
Run the following command:
$./Configure -- disable-shared (preferred)
Or:$./Configure -- disable-static -- enable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
6 compile x264 (optional)
Press last_x264.tar.bz2 to the Directory D: \ FFMPEG \ and double-click "C: \ mingw \ msys \ 1.0 \ msys. bat, start mingw32, switch to the x264 Directory: D: \ FFMPEG \ x264-20111124-2245
$ CD/d
$ CD FFMPEG
$ X264-20111124-2245 CD
Run the following command:
$./Configure -- enable-shared -- disable-ASM -- enable-pthreads
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.

 

PS: If no -- enable-pthreads exists, the thread library compilation error is returned, as shown below:

CC      libavutil/atomic.olibavutil/atomic.c:101:2: Fehler: #error "Threading is enabled, but there is no implementation of atomic operations available"common.mak:48: recipe for target 'libavutil/atomic.o' failedmake: *** [libavutil/atomic.o] Error 1

Reference: http://avcodec.org/trac/ffmpeg/ticket/2363

7. Compile Xvid (optional)
Xvidcore-1.3.2.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat, start mingw32, and switch to the xvidcore Directory: D: \ FFMPEG \ xvidcore \ build \ Generic
$ CD/d
$ CD FFMPEG
$ CD xvidcore/build/generic
Run the following command:
$./Configure -- prefix = C:/mingw/msys/1.0/local
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
Note that the path is added to the compilation.
If the following error occurs during make: cc1.exe: Error: Unrecognized command line option '-MnO-cygwin', go. /modify platform in xvidcore \ build \ Generic before make after configure. inc file, directly Delete "-MnO-cygwin" in it ".
Specific can refer to: http://ffmpeg.zeranoe.com/forum/viewtopic.php? F = 5 & t = 111 in the second floor of the answer, if he says: I recommend re running. /Bootstrap. sh after you do this ., I found that it is not very good, just run Bootstrap. after SH, platform. the INC file will be restored and. /configure will also restore the file, so I chose. /configure is modified before make. It can be compiled successfully. Currently, no Xvid is verified to be available.
8 compile faad2 (optional)
Faad2-2.7.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to faac2 Directory: D: \ FFMPEG \ faad2-2.7
$ CD/d
$ CD FFMPEG
$ Faad2-2.7 CD
Run the following command:
$./Bootstrap
$./Configure -- disable-static -- enable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
9 compile faac (optional)
Faac-1.28.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to faac2 Directory: D: \ FFMPEG \ faac-1.28
$ CD/d
$ CD FFMPEG
$ Faac-1.28 CD
Run the following command:
$./Bootstrap
$./Configure -- disable-static -- enable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
10 compile vo-aacenc (optional)
Vo-aacenc-0.1.1.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to the Vo-aacenc Directory: D: \ FFMPEG \ vo-aacenc-0.1.1
$ CD/d
$ CD FFMPEG
$ Vo-aacenc-0.1.1 CD
Run the following command:
$./Configure -- disable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
11 compile Amr-Nb and Amr-WB (available in earlier FFMPEG versions)
Before compiling amrnb and amrwb, you need to do some other preparation work:
A first searches for and downloads the wget tool online. decompress the tool and place it in the C: \ mingw \ bin directory. This tool is a web download tool used to automatically download the 3GPP source code during compilation.
B first to the http://downloads.sourceforge.net/gnuwin32/unzip-5.51-1-bin.zip download unzip-5.51-bin.zip and decompress, and unzip.exe unzip-5.51-1-bin \ binto c: \ mingw \ bin directory, this tool is used to automatically decompress the 3GPP source code during compilation.
Amrnb-7.0.0.2.tar.tar pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to the amrnb Directory: D: \ FFMPEG \ amrnb-7.0.0.2
$ CD/d
$ CD FFMPEG
$ Amrnb-7.0.0.2 CD
Run the following command:
$./Configure -- disable-static -- enable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
Amrwb-7.0.0.4.tar.tar pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to amrwb Directory: D: \ FFMPEG \ amrwb-7.0.0.4
$ CD/d
$ CD FFMPEG
$ Amrwb-7.0.0.4 CD
Run the following command:
$./Configure -- disable-static -- enable-shared
$ Make
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
12 compile opencore-AMR and Vo-amrwbenc (optional)
Opencore-amr-0.1.2.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted.
If opencore-amr-0.1.1.tar.gz is used, comment out the following makefile lines.
File:./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
File:./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
Switch to the opencore-Amr Directory: D: \ FFMPEG \ opencore-amr-0.1.2
$ CD/d
$ CD FFMPEG
$ Opencore-amr-0.1.2 CD
Run the following command:
$./Configure -- disable-shared
$ Make cc = gcc
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
Vo-amrwbenc-0.1.1.tar.gz pressed to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat ", start" mingw32 ". If it has been started, it will no longer have to be restarted. Switch to the Vo-amrwbenc Directory: D: \ FFMPEG \ vo-amrwbenc-0.1.1
$ CD/d
$ CD FFMPEG
$ Vo-amrwbenc-0.1.1 CD
Run the following command:
$./Configure -- disable-shared
$ Make cc = gcc
$ Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.
13 compile SDL (optional)
SDL-1.2.14.tar.tar decompress to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat, start mingw32, switch to the SDL Directory: D: \ FFMPEG \ SDL-1.2.14, the switching method is as follows:
$ CD/d
$ CD FFMPEG
$ SDL-1.2.14 CD
Run the following command:
./Configure
Make
Make install
The compilation result is in the directory c: \ mingw \ msys \ 1.0 \ local.

Note: The hosts file is enough. The following modifications and copies are required for self-compilation or direct use of the compilation.
Use ultraedit to open the SDL-config file under c: \ mingw \ msys \ 1.0 \ Local \ bin
Set prefix =/usr to: prefix = C:/mingw.
Here: C:/mingw is the installation path of mingw. Please modify it according to your installation. In order for msys to recognize SDL during compilation and enable SDL support yes for compilation, set C: copy the \ mingw \ msys \ 1.0 \ Local compilation result bin, include, and lib to the corresponding directory of c: \ mingw.
14. Copy the compilation result
C: \ mingw \ msys \ 1.0 \ Local to D: \ FFMPEG \ ffmpeg-0.8.6
Copy bin to bin
Copy include to include
Copy lib to lib
Of course, you can skip this copy process, as long as you point the path to c: \ mingw \ msys \ 1.0 \ Local during compilation.
15 compile FFMPEG
Ffmpeg-0.8.6.tar.bz2 decompress to: D: \ FFMPEG \ directory, double-click "C: \ mingw \ msys \ 1.0 \ msys. bat, start mingw32, switch to the FFMPEG Directory: D: \ FFMPEG \ ffmpeg-0.8.6, the switching method is as follows:
$ CD/d
$ CD FFMPEG
$ Ffmpeg-0.8.6 CD
If your "mingw32" is not closed, you can directly switch the path to: D: \ FFMPEG \ ffmpeg-0.8.6.
Run the following command:
$./Configure -- enable-shared -- disable-static -- enable-ffplay
-- Enable-nonfree -- enable-memalign-hack
Enable-libmp3lame
-- Enable-GPL -- enable-libx264
-- Enable-libxvid
-- Enable-faad -- enable-libfaac
-- Enable-libvo-aacenc
-Enable-version3 -- enable-libopencore-amrnb
-- Enable-libopencore-amrwb -- enable-libvo-amrwbenc
-- Extra-cflags =-ID:/FFMPEG/ffmpeg-0.8.6/include
-- Extra-ldflags =-ld:/ffmpeg/ ffmpeg-0.8.6/lib
Please wait for a while. The above commands cannot be directly wrapped and changed according to the FFMPEG version. For details, see./configure -- help, you know...
$ Make
It takes a long time to complete compilation.
To summarize the compilation results, run the following command:
$ Make install
Wait for completion. In c: \ mingw \ msys \ 1.0 \ local, a bin1_demo-libfolder is generated, including ffmpeg.exe0000ffplay.exe0000ffprobe.exe, DLL, Lib, and header file.
16 run the test
Run javasffplay.exe directly in double-click mode. If you are prompted that the "pthreadgc2.dll" file does not exist, you can package "pthreadgc2.dll" to directly copy it to the current directory or put it in the system directory c: \ windows \ system32.

Ffplay F:/xxx.mp4

Refer:
Http://blog.csdn.net/yangshu168/archive/2010/01/17/5204269.aspx
Http://blog.csdn.net/himulakensin/article/details/6693457
Http://blog.csdn.net/huangxiansheng1980/article/details/5712003

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.