#1 Technical Series : How to compile FFMPEG under Cygwin
FFmpeg as we know is an extremely resourceful multimedia toolkit providing range of media operations to record, encode, decode, transcode, convert and stream audio and video files with wide ranging support for multiple codecs, containers and file formats. FFMPEG is an open source framework and the technology powering some of the largest online content aggregators and video platforms. While being predominantly Unix based, it is also available under windows environment both as binary executables and for compilation. Cygwin, which provides an ideal Unix like environment uses cross compilers to build and execute FFMPEG on Windows platform. This post attempts to provide easy and step-by-step instructions to setup and compile FFmpeg under Cygwin. These steps are applicable for both 32 and 64 bit environment.
Setup Essentials: Windows OS, Cygwin, FFmpeg source code
Step 1: Setup Cygwin under Windows
- Download setup-x86.exe for the version of windows (32 bit / 64 bit)
- Run Setup.exe
- Select default option install from internet
- Select folder where Cygwin files will be installed
- Select type of connection and download site. In case you encounter problem with selected download site (e.g. download stops), cancel it, relaunch setup.exe and select another download site to proceed further.
- Cygwin offers loads of packages, will recommend installing following basic packages needed for our setup. Cygwin provides easy mechanism to add additional packages. Under select package interface, make the following selections
- Select entire base package
- Devel : binutils, gcc-core, git, make, mingw-runtime, subversion, yasm
- Text : Texi2html
- Util : diffutils , dos2unix
- Net: curl (Updated for newer version of cygwin)
Pressing next automatically resolves package dependencies and proceeds for installation. To add more packages execute setup.exe and re-launch package window. Search and select the package for installation, one can search specific package from the search box available on the top. On completion, select option to create icon on desktop for easy launch. For additional details, refer Cygwin site.
Step 2 : Download FFmpeg under Cygwin
Launch Cygwin which presents a Unix shell interface, download FFmpeg source code from ffmpeg.org using git
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
Above command downloads the latest version of ffmpeg code in the newly created “ffmpeg” folder
Step 3: Compile FFmpeg under Cygwin
Go to the ffmpeg folder and execute following set of commands for compilation
dos2unix configure
The command converts the file configuration into Unix format
make distclean
The command removes any built sources to ensure fresh build.
UPDATE (Apr 15, 2015)
For older version of ffmpeg (pre 2.2 release), use below two commands
./configure –enable-static –disable-shared
The command checks if everything needed is available and instruction to make a static build.
./configure –enable-shared –disable-static –extra-cflags=-fno-reorder-functions
UPDATE (Apr 15, 2015)
Current version of ffmpeg (anything 2.2 onward) does not support –enable-static and –disable-shared option. Please use below command if using a more recent version of ffmpeg.
$ ./configure –enable-shared –disable-static
make
The command compiles ffmpeg source using the makefile created from configure command executed earlier.
make install
The command installs to key utilities ffmpeg and ffserver in the ffmpeg folder. ffmpeg tool provides options for media file operations and ffserver is multimedia streaming server.
FFMPEG help
FFMPEG provides extensive online help as well as command line options as below
- ffmpeg -h ( prints basic options),
- ffmpeg -h long (prints basic and advanced tool options )
- ffmpeg -h full (prints complete list of options, including shared and private options for encoders, decoders, demuxers, muxers, filters, etc.)
FFMPEG commands follow a standard structure for parameter passing
ffmpeg [input parameters] -i [input file] [output parameters] [output file]
Example 1 : Command to convert an avi file (input.avi) into a mpg file (output.mpg)
$ ffmpeg -i input.avi output.mpg
Once can also access files from the windows file system, e.g. to access a file under temp in D drive, use
$ ffmpeg.exe -i /cygdrive/d/temp/input.avi /cygdrive/d/temp/output.mpg
Reference source