_ FFMPEG compilation in Windows

Source: Internet
Author: User

Http://blog.csdn.net/himulakensin/article/details/6693457

The FFMPEG open-source library is developed in Linux and is a comprehensive audio and video codec library. Compiling and translating lib libraries for development in Windows is indeed more difficult than programming in Linux, baidu has been working for a long time. Based on others' opinions, he finally compiled the libraries that he needed for development (in the form of DLL, the Lib with DLL, and the static library won't be compiled)

Compilation environment: Windows XP and vs2008 (vs2003 was also compiled once). Most of the mingw + msys Baidu statements are troublesome, especially when downloading some mingw + msys files, with the update of time, it is actually not that troublesome.

1. First, download mingw and dig (because it is the method for downloading files ).... The mingw + msys system has been installed. The installation path is c: \ mingw,
The msys directory is c: \ mingw \ msys \ 1.0. The following statements are based on this path (any path can be used)

2. Edit the c: \ mingw \ msys \ 1.0 \ msys. BAT file and add a line at the beginning.

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

The following path is the corresponding path of vs200x installed on your machine. When you add this line to compile FFMPEG, the corresponding lib of DLL will be called in windows, so that vs200x can be called conveniently. It seems that ffmepg will be produced, xvid, x264, and some other libraries were not generated. FFmpeg is so kind.

3. Go to the FFMPEG official website to renew

Note: rewrite is placed on c: \ windows \ system32 (mainly to save the need to add environment variables). It is best to get one for NASM, and some libraries are often compiled and used. It doesn't matter if you don't put it, that is, the generated items do not support assembly, and the speed will be greatly affected.

4. double-click c: \ mingw \ msys \ 1.0 \ msys. BAT Run, enter Directory D: \ pifu \ ffmpeg-0.8 \ ffmpeg-0.8 it and CMD run some difference, the right slash needs to be replaced with the left slash, then drive letter D: you also need to change/d above input CD/D/pifu/ffmpeg-0.8/ffmpeg-0.8, you can also split

CD/d

CD pifu

CD ffmpeg-0.8

Cd ff *

And so on... (* Can replace characters)

Enter

./Configure -- enable-shared -- disable-static -- enable-memalign-hack

Wait for a long time. Enter the value after the start of $.

Make

Wait for a long Compilation Time. Enter the value after starting with $.

Make install

Compilation process ended

The required results are in the C: \ mingw \ msys \ 1.0 \ localdirectory, and the corresponding header file, such as dllplus liband ffmpeg.exe, runs the program.

Is it easy.

Note: The make Command actually contains the generated DLL and Lib in the FFMPEG directory, however, it is recommended that you execute the make install command because it will sort out the required header files for you (too considerate, I think too many copies, and it is too troublesome and incorrect to choose ), then the DLL file will be several times smaller (the principle is unclear ). The first command. /configure with the make and make install commands, you can use mingw in Windows to compile many open-source libraries from Linux. /configure -- help. /configure can be configured with those switches. It does not matter if the switch is incorrect or missing. msys will remind you that it is considerate. Generally./configure can be executed, so there is a configure file under the root directory, which can be opened using WordPad or other document editing tools (such as UE)

D: \ pifu \ ffmpeg-0.8 \ configure file under the ffmpeg-0.8, which can find the files listed by./configure -- help. There is such a paragraph

External library support:
-- Enable-avisynth enable reading of avisynth script files [No]
-- Enable-bzlib enable bzlib [autodetect]
-- Enable-libcelt enable Celt/opus decoding via libcelt [No]
-Enable-frei0r enable frei0r Video Filtering
-- Enable-libopencore-amrnbenable AMR-NB de/encoding via libopencore-amrnb [No]
-- Enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [No]
-- Enable-libopencv enable Video Filtering via libopencv [No]
-- Enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
And libraw1394 [No]
-- Enable-libdirac enable Dirac support via libdirac [No]
-- Enable-libfaac enable faac support via libfaac [No]
-- Enable-libfreetype enable libfreetype [No]
-- Enable-libgsm enable GSM support via libgsm [No]
-- Enable-libmp3lame enable MP3 encoding via libmp 3lame [No]
-- Enable-libnut enable nut (de) muxing via libnut,
Native (de) muxer exists [No]
-- Enable-libopenjpeg enable JPEG 2000 decoding via openjpeg [No]
-- Enable-librtmp enable rtmp [e] support via librtmp [No]
-- Enable-libschroedinger enable Dirac support via libschroedinger [No]
-- Enable-libspeex enable speex decoding via libspeex [No]
-- Enable-libtheora enable theora encoding via libtheora [No]
-- Enable-libvo-aacenc enable AAC encoding via libvo-aacenc [No]
-- Enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [No]
-- Enable-libvorbis enable Vorbis encoding via libvorbis,
Native implementation exists [No]
-- Enable-libvpx enable Vp8 support via libvpx [No]
-- Enable-libx264 enable H.264 encoding via x264 [No]
-- Enable-libxavs enable AVS encoding via xavs [No]
-- Enable-libxvid enable Xvid encoding via xvidcore,
Native MPEG-4/Xvid encoder exists [No]
-- Enable-mlib enable sun medialib [No]
-- Enable-zlib enable zlib [autodetect]

These are libraries that FFMPEG does not have but can be extended.

5. extended library, FFMPEG itself does not support MP3 encoding, and I strongly hope to be able to compile MP3

Go to uninstall install and execute. /-- help before Configure. If there is a static or dynamic library, disable the dynamic library and select static library (you can ignore it, of course) after the execution, the library of lame (which actually contains the MP3 encoding) will be under c: \ mingw \ msys \ 1.0 \ Local (the output path of the library ).

Yes, but it is best not to bother with it.) other libraries can also perform the same operation. I tried x264 Xvid libvo-aacenc libvo-amrwbenc zlib, the first two websites are easy to find and download, and they are all searched on SourceForge. /Add assembly and thread support When configuring configure (if supported)

Then ffmepg uninstalls (you can also come back), enter the Directory D: \ pifu \ ffmpeg-0.8 \ ffmpeg-0.8, execute

Make uninstall

./Configure uses my parameters as an example (there is no carriage return or the like below ):

./Configure -- enable-shared -- disable-static -- enable-w32threads -- enable-m
Emalign-hack -- enable-libvo-aacenc -- enable-libvo-amrwbenc -- enable-libmp3lame-
-Enable-zlib -- extra-cflags =-I/usr/local/include -- extra-ldflags =-L/usr/local/Li
B -- enable-version3

-- Extra-cflags and -- extra-ldflags indicate the path to call other libraries.

Finally, I did not add Xvid and x264. Xvid is a codec for MPEG4 videos and has powerful functions. FFMPEG supports compiling MPEG4 videos. X264 is highly efficient for H.264 encoding. FFMPEG does not support H.264 encoding. I didn't add these two databases: I used a version of VFW of x264, and then used the FFMPEG Library Supported by x264, an asserted error occurs during debugging in a process (the release version is not available). Therefore, x264 is not added, and the extra encoding efficiency of x264 is higher than that of FFMPEG, then I am worried that Xvid may encounter the same situation and will not be added.

Speaking of XviD, when you use Xvid, Please hate DivX.

X264 I hung up a great VFW version on csdn (first hanging) http://download.csdn.net/source/3463887

Suitable for development. The efficiency is better than the latest x264, and compiled with mingw. Unfortunately, no download is required. It is estimated that the resource will be deleted soon.

6. The last point is irrelevant.

The generated DLL and Lib have several groups, the file is actually the same, need to take a file similar to the avcodec-53.dll and avcodec-53.lib, *. Lib name

It doesn't matter, but the DLL name is limited. Use ue to edit avcodec-53.lib, which contains a pile of avcodec-53.dll characters. Sometimes I want to get rid of it.

The DLL name, because, after all, people are afraid to call other people's libraries to generate FFMPEG libraries. name conflicts are very dangerous.

This can be a simple operation, with the UE inside the avcodec-53 size match to change to another name, (Name Length needs to be the same as before, not the same

Knots themselves to try), avcodec-53.dll also do this thing, and is generated in ffmpeg dll used in the avutil-51.dll, avcodec-53.dll

The corresponding avutil-51.dll character needs to be changed accordingly. (The file name mentioned above is just an example, which may be changed later)

Search for files containing example in the FFMPEG directory (there should be two files ), the swscale library of FFMPEG library generated above should be easily called to write data according to the code, which realizes the conversion of the original image format (many formats are supported) and the change of the size, you only need to call two methods (add one release method) to easily solve the problem and the efficiency is very good. We recommend that you use

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.