Compile FFMPEG full manual in Windows

Source: Internet
Author: User
Tags tortoisesvn
Almost all of the content in this article comes from FFMPEG on Windows. However, due to the domestic network blockout, it is difficult to access the content under this domain name. Therefore, on the one hand, I have translated the content according to my own understanding and practices, on the other hand, it is also to provide a convenient reference method.

Note:

  1. For the word compile and build, This article uses the word compile in a unified way, according to the context readers should be able to distinguish semantic differences.

The purpose of this article is to provide all the help related to FFMPEG in windows. It was initially a hands-on tutorial for msys + mingw system compilation. Now it also adds how to link the library generated by FFMPEG in your project (C ++, C #).
We will not discuss cygwin, because it basically works in the same way as UNIX systems. Before you begin, you must clarify the following points:

  1. Because msvc ++ does not strictly follow the C standard, FFMPEG cannot be compiled using msvc ++ and will not be supported in the future. Therefore, the entire compilation process must be completed using the msys + mingw system.
  2. If you choose to compile a dynamic link library (DLL), these libraries will be used in the same way as other dynamic link libraries. You can use msvc ++ to link these libraries to your program. In this case, msvc ++ is supported.

This guide is very lengthy. If you have previously experienced compiling open source software, you can try to read this article. It should be much shorter and can work normally only with some minor adjustments.
HoweverIf you encounter any problemsWhen you report an error to the FFMPEG email list, firstRead this article carefullyIt is very intuitive, and the details of many places may be too detailed. We try to cover all possible errors. If you follow the methods described above accurately, you will not have any problems with FFMPEG in windows.Do your best to solve your problemsMost FFMPEG developers do not use windows, so they cannot help you.

Preparing the content here may have nothing to do with this article, but I don't want to leave anything that may go wrong. For most people, this part can be skipped. You need an decompressed tool to support the "* .tar.gz" and "* .tar.bz2" files. You need to extract these packages to the specified directory. If you already have such a program and know how to decompress it to a specific directory, read and prepare the msys + mingw system. Here I will demonstrate how to use 7-Zip or WinRAR for decompression. 7-Zip is recommended because it is open source and free.

  • 7-zip
  • WinRAR

Prepare the msys + mingw system to obtain the latest msys + mingw system. Note the following version requirements:

  • Do not use Bash of 2.0.4. This is flawed. 2.05b Bash is used to compile FFMPEG, but Version 3.1 is recommended.
  • Use msys-1.0.dll-SNAP-1.0.11-2006.04.23
  • Don't use binutils-2.15.91-20040904-1, it cannot be the correct link.

If the installation and configuration are complete, read the next section to obtain FFMPEG using SVN. Otherwise, perform the following steps in sequence.

  • Install msys
  • Install mingw
  • Integrate mingw and msys

Obtain FFMPEG using SVN. If you already know how to obtain the source code of FFMPEG, read the next section for compilation. Because the source code of FFmpeg is stored in the svn repository, you must use the command line program or graphical interface program to access it. I personally recommend tortoisesvn because it works very well with Windows resource manager, so I will only introduce how to use tortoisesvn. Compile

  • Compile static library
  • Compile a dynamic library

Link

  • Use msvc ++ to link the dll library
  • Create output_example.exe with msvc1_example

To compile ffplay, you must install SDL-devel in advance.

  1. Decompress the package.
  2. SetLibCopy all files underC:/msys/mingw/lib.
  3. SetIncludeCopy all files underC:/msys/mingw/include.
  4. SetBinUnder i386-mingw32msvc-sdl-config copyC:/msys/mingw/binAnd rename itSDL-config.
  5. SetBinCopy SDL. DLLC:/msys/mingw/bin.
[Copy to clipboard]

Code:

Sdl.dll.pdf is in the ffplay.exe path before the program starts. In the msys environment, there is no problem in running ffplay.exe in the pathenvironment variable of mingw/bin. If you want to run the message service in an external department, sdl.dllshould be copied to the same directory as ffplay.exe.

Now you can recompile FFMPEG statically or dynamically according to the previous method. After running the configure script, it will find SDL and ffplay correctly.

Third-party library support

You mustFull understandingTo compile the dynamic library.

When adding other libraries to FFMPEG binary files, you must first consider whether the libraries are statically or dynamically linked to FFMPEG. Do not mix this with the FFMPEG static/dynamic link library. You can link the third-party library to FFMPEG statically, but the FFMPEG library is a dll library Dynamically Loaded.

Consider this situation: If you want to replace xvidcore but do not want to re-compile FFMPEG, you should compile xvidcore into a dynamic link library.

Next, consider where these third-party libraries are installed in the msys system.

For the vast majority of libraries, if you install them to the default path, you have to pass additional parameters to the FFMPEG configure script so that these libraries can be found during compilation.

If you install these libraries to the GCC defaultIncludeAndLibPath, you do not need to specify these parameters. If you want to separate the dynamic library from the static library, you have to specify the path. This path is calledPrefix. If you install the library in a non-GCC default search path, you mustConfigureThe script transmits the path information.

[Copy to clipboard]

Code:

-- Extra-ldflags =-L <prefix>/lib -- extra-cflags =-I <prefix>/include

Similar to this:

[Copy to clipboard]

Code:

./Configure -- enable-memalign-hack -- enable-mp3lame -- extra-ldflags =-L/usr/local/lib -- extra-cflags =-I/usr/local/include

In msys, the default GCC path is/mingw. If you install the DLL of these libraries, make sure that your application can find the corresponding dll in the path environment variable. I will show how to install the following libraries:

  • Zlib
  • Mp3lame
  • Xvidcore
  • Libogg
  • Libvorbis
  • Faad
  • Faac
  • Amr_nb
  • Amr_wb
  • Libdts
  • Libgsm
  • X264

Http://www.aurora-x.net/wiki/CompileFFmpegWindows:

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.