Media & Entertainment Industry Trends, Technology and Research

#1 Technical Series : How to compile FFMPEG under Cygwin

Posted In Technical - By Nitin Narang on Thursday, January 9th, 2014 With 12 Comments

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 ffmpeg under Cygwin on Windowsformats. 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
  1. Select entire base package
  2. Devel  : binutils, gcc-core, git, make, mingw-runtime, subversion, yasm
  3. Text : Texi2html
  4. Util  :  diffutils , dos2unix
  5. 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

ffmpeg git clone command

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 

configure for static build

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

configure makefile command

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

ffmpeg configure option

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)

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

About - Digital Media Technology Consultant. I have passion for TV technology, digital convergence and changing face of Media and Entertainment industry.

  • Albert

    I guess, this options are not allowed in ffmpeg 2.1.3:
    –enable-static –disable-shared

    • Nitin Narang

      Albert, 2.1.4 (Fourier) is the latest ffmpeg version released on 24 Feb 2014 and above mentioned steps are supported. At time of writing this post 2.0.3 was released version and mentioned steps worked well. Would recommend to use the latest version from git .

  • Pingback: FFMPEG shell commands()

  • kotofos

    Texi2html should be texi2html. And should be –enable-static. The problem is that site converted “–” to “–”.

  • aprogrammer

    Thank you for the post. You can add here some additional libs and codecs for ffmpeg support all kind of audio and video formats like listed here – http://sysadm.pp.ua/linux/video-streaming/ffmpeg-build.html .

  • Basanth Kumar Varma Alluri

    I couldn’t find these 2 packages in cygwin. Text : dos2unix & Web : curl. Can any one suggest me what could be the wrong?

    • You can install the additional packages using the cygwin setup either from local installed directory or remotely. Setup will provide the option to select a package, it automatically takes care of dependencies

  • ali sheikhli

    that was helpful thank you… but i have some issues if you don’t mind…. when i did ./configure it told me to install yasm but i added disable yasm so any recommendation like ok no problem or insallation of yasm i tried but didn’t work out …. thanks again

    • Include yasm package from Devel. Also note the change in configure parameters with more recent version of ffmpeg

  • Kev

    How do I build a 32 bit version of ffmpeg on Windows 7 64 bit please?

  • Pingback: how to use ffmpeg in android? [duplicate] - DexPage()

  • Mahesh

    Thank you, This was highly useful.