Ubuntu Cross-compiling ffmpeg Windows SDK

Source: Internet
Author: User

Write in front

  FFmpeg is an open source and cross-platform audio and video solution, collection, transcoding, streaming, project libavcodec codec module and libavformat Media Format module, Support Very very rich codec format and container encapsulation format, is to do media related development work must master and draw lessons from a project. Custom and compile ffmpeg is to do streaming media development sooner or later to face, Linux platform relatively simple, Windows platform is more troublesome. The purpose of this article is to describe in detail how to compile and customize ffmpeg based on the Ubuntu Cross-compilation environment.

An overview

FFmpeg is primarily based on Linux, and of course it supports windows, but it does not support the Visual Studio Series IDE (because it uses a lot of C99 features, and VS does not support C99), so to use on Windows, It must be compiled with MinGW or Cygwin, or build a Windows cross-compilation environment on Linux, which is simpler. Here is a Web site http://ffmpeg.zeranoe.com/, the author provides ffmpeg has been compiled version of the Windows, including statically connected, dynamically connected, as well as the SDK, basically compiled every few days. You can go up and look, if it compiles to meet your needs (last time it seems to have not joined LIBFAAC, now do not know), and you do not bother to compile, you can use it. Friends who are not familiar with Linux may not want to continue looking down, please don't worry, Ubuntu installation and use is very simple, directly in the virtual machine to use the line. When compiling, you just need to use a few simple commands.

Two environment preparation

1. Ubuntu Linux, I use Ubuntu 11.10, installed in the VMware Workstation

2. MinGW Compile the environment , we would like to thank, Zeranoe, it did an automatic download and compile FFmpeg required MinGW and other tool chain script, go to http://ffmpeg.zeranoe.com/blog/ Download the latest "Minggw-w64 Build Script 2.8.2". After extracting a new directory to put it in (my directory is /home/haibindev/studio/mingw-w64/), and then open the terminal, CD to Mingw-w64 directory, execute "chmod +x mingw-w64-build-2.8.2 "so that this script can be executed. After running "./mingw-w64-build-2.8.2", you can follow the prompts to do it. If it prompts you for a missing dependent library, follow its prompts to install the dependent library, by executing the "sudo apt-get Install library name".

3. Setting the terminal's environment variables

Execute the command. (Note that if you close the terminal or create a new terminal, you need to re-execute this command.) )

Export path= "$PATH:/home/haibindev/studio/mingw-w64/mingw-w64-i686/bin"

Three download FFmpeg source code and the source code of the codec library you need

This does not need to do any introduction, first to ffmpeg official website, download ffmpeg source code, and then Google you need to encode and decode library, to the relevant website to download. I compiled a total of download the following code to do your reference.

libx264 libfaac libmp3lame libopenjpeg libogg Libspeex libvorbis libtheora libxvid ffmpeg

Download after the decompression, and then unified into a directory, my directory is /home/haibindev/studio/opensource/. is the family blessing (Build-ffmpeg is compiled ffmpeg working directory, described below, FreeType I did not compile).

Quad compilation

For convenience, I put all the library compiled results into a unified directory /HOME/HAIBINDEV/OPENSDK, see the following compile command.

In addition to the first command, the rest is the Configure command, and after execution, you need to execute the make command and then executethe make install. I'm not going to write it anymore.

1. Execute the following command first

Ln-s "/usr/bin/pkg-config"/home/haibindev/studio/mingw-w64/mingw-w64-i686/bin/i686-w64-mingw32-pkg-config

2. libx264

./configure--enable-static--enable-win32thread--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk-- cross-prefix=i686-w64-mingw32-

3. LIBFAAC

./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static--disable-shared--with-mp4v2= No

4. Libmp3lame

cflags=-dforceinline=./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static-- Disable-shared--disable-frontend

5. Libopenjpeg

./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static--disable-shared

6. Libogg

./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static--disable-shared

7. Libspeex

./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static--disable-shared-- Disable-oggtest

8. Libvorbis

9. Libtheora

./configure--host=i686-w64-mingw32--prefix=/home/haibindev/opensdk--enable-static--disable-shared-- Disable-oggtest--disable-vorbistest--disable-sdltest--with-ogg-includes=/home/haibindev/opensdk/include-- With-ogg-libraries=/home/haibindev/opensdk/lib

Ten. Libxvid

./configure--host=i686-w64-mingw32--PREFIX=/HOME/HAIBINDEV/OPENSDK--disable-pthread

ffmpeg .

First create the /home/haibindev/studio/opensource/build-ffmpeg, then CD to the directory, execute

.. /ffmpeg-0.8.7/configure--disable-static--enable-shared--enable-version3--ENABLE-GPL--enable-nonfree-- Disable-pthreads--enable-w32threads--enable-runtime-cpudetect--enable-memalign-hack--enable-libfaac  -- Enable-libmp3lame--enable-libopenjpeg--enable-libspeex--enable-libtheora--enable-libvorbis--enable-libx264-- Enable-libxvid--enable-zlib--enable-cross-compile--target-os=mingw32--arch=x86--prefix=/home/haibindev/opensdk /ffmpeg--cross-prefix=i686-w64-mingw32---extra-cflags= "-i/home/haibindev/opensdk/include"--extra-ldflags= "-L/ Home/haibindev/opensdk/lib "

Note that when compiling XviD, you need to edit the Configure file and then delete the "-mno-cygwin" field in it, otherwise make will fail, prompting-mno-cygwin to be invalid. Libmp3lame hit in the front of the "cflags=-dforceinline=" is to prevent a compilation error in Mp3lame, remember to bring.

After the compilation is successful, the FFmpeg Win32 SDK appears in the /home/haibindev/opensdk/ffmpeg , and the bin directory is all the files we need.

Five verification of compiled programs

Copy to Windows, run Ffmpeg.exe in the command, see

Verify, do a transcoding operation, execute

Ffmpeg.exe-i S.avi-vcodec Libx264-acodec LIBFAAC s.mp4

Run normally, generated 264 encoding and AAC encoded, MP4 file, play normal, OK.

Six last words.

Please do not forget to compile the Configure after the implementation of make and made install! In addition, must see clearly I put out the order, put my directory, replace your directory, do not copy directly, it is not, because you do not call Haibindev:). If the library has a compile error when make, simply modify the source file to get it done.

FFmpeg has a lot of configuration options, you can customize it in depth, you can compile the Avcodec very small, you can do their own research.

Ubuntu Cross-compiling ffmpeg Windows SDK

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.