0x15e / ffmpeg-windows-build-helpers

Helper script for cross compiling some media tools for windows, like customizable ffmpeg.exe (with or without fdk_aac), and other bonuses like mplayer, vlc, mp4box, mxf, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ffmpeg-windows-build-helpers

This helper script lets you cross compile a windows 32 or 64 bit version of ffmpeg/mplayer/mp4box.exe, etc. including many dependency libraries they use.

To run the script, either build in windows, or build in linux (cross compiles to build windows executables). Building in linux takes less time overall, but requires a linux box or VM. Building in windows takes "quite awhile" but avoids the need of needing linux installed somewhere.

To build in windows (uses the native'ish cygwin):

obtain repository: download zip file:

https://github.com/rdp/ffmpeg-windows-build-helpers/archive/master.zip

and unzip, or clone the repository:

 c:\>git clone https://github.com/rdp/ffmpeg-windows-build-helpers.git

Next run one of the "native_build/build_locally_XXX.bat" file.

  • build_locally_fdk_aac_and_x264_32bit_fast: Just libx264, fdk aac, and FFmpeg, and takes about 1 hour. Easiest way to get fdk aac, if you don't know which you want, use this one.

  • build_locally_with_various_option_prompts: Has FFmpeg and many dependency libraries. Prompts for whether you'd like to also include fdk/nvenc libraries, 32 and/or 64 bit executables. Can take 6 hours or more.

  • build_locally_gpl_32_bit_option: Same as option prompts above, but 32bit non-fdk auto selected.

    For the long running builds, recommend start it, wait for it to give you prompts (if it does, it asks them as a bunch up front after installing cygwin) then let it build overnight :)

Or second option: build it from linux (much faster, takes 2 hours for the "options" build, requires a linux box or VM with linux guest running on a windows box): In some type of Linux box (VM or native, or you could even create a VM temporarily, ex: digitalocean [1], [use it, then destroy your droplet]):

Download the script 
git clone this repo:
$ git clone https://github.com/rdp/ffmpeg-windows-build-helpers.git
$ cd ffmpeg-windows-build-helpers

Or do the following in a bash prompt instead of git clone:
$ mkdir ffmpeg_build
$ cd ffmpeg_build
$ wget https://raw.github.com/rdp/ffmpeg-windows-build-helpers/master/cross_compile_ffmpeg.sh -O cross_compile_ffmpeg.sh
$ chmod u+x cross_compile_ffmpeg.sh

Now run the script:

$ ./cross_compile_ffmpeg.sh

And answer the prompts.
It should end up with a working static ffmpeg.exe within the "sandbox/*/ffmpeg_git" director(ies).

Another option instead of running ./cross_compile_ffmpeg.sh is to run

$ quick_cross_compile_ffmpeg_fdk_aac_and_x264_using_packaged_mingw64.sh script.

The "quick" part being the important part here, this one attempts to just uses your local distributions' mingw-w64 package for the cross compiler, thus speeding up compilation dramatically.

OS X users, follow instructions for linux above (it should "just work" no VM needed, using cross compiling).

Also NB that it has some other optional command line parameters you can pass it, for instance building a shared FFmpeg build (libavcodec-56.dll type distro), building mp4box/mplayer/vlc, 10 bit libx264, etc. Run it like

./cross_compile_ffmpeg.sh -h

to see all the various options available. Also NB that you can also "cross compile" mp4box.exe if you pass in the appropriate command line parameter. Also NB that you can also "cross compile" {mplayer,mencoder}.exe if you pass in the appropriate command line parameter too. Also NB that you can also "cross compile" vlc.exe if you pass in the appropriate command line parameter too [currently broken, ping if you want it to work again]. To enable Intel QSV (vista+ compatible only dependency so not enabled by default) use option --build-intel-qsv=y

If you want to customize your FFmpeg final executable even more (remove features you don't need, etc.) then edit the script

  1. Add or remove the "--enable-xxx" settings in the build_ffmpeg method (under config_options) near the bottom of the script. This can enable or disable parts of FFmpeg that you don't need, or want more, etc.

If you really want to customize it, you can add new dependencies:

  1. You can write custom functions for new features you want to integrate, make sure to add them to the build_dependencies() functions and also include the corresponding "--enable-xxx" settings to the build_ffmpeg() function under the config_options
  2. There are some helper method do_XXX etc. for checking out code, running make only once, etc. that may be useful.

Also NB that you can optionally create a "somewhat more machine optimized builds" by modifying an appropriate --cflags parameter, like --cflags=-march=athlon64-sse2 or what not.
So if you're cross compiling it on the box you'll end up targeting it for, you could build it like --cflags=-march=native to get a slightly faster executable Unfortunately, after doing some benchmarking, it seems that modifying the CFLAGS this way (at least using libx264) doesn't end up helping much speed-wise (it might make a smaller executable?) since libx264 auto detects and auto uses your cpu capabilities anyway, so...until further research is done, these options may not actually provide significant speedup. Ping me if you get different results than this, and you may be wasting your time using the --cflags= parameter here.

NB that this may contain slightly older/out of date dependency versions, so there may be a chance of security risk, though FFmpeg itself will be built from git master by default, with all the latest and greatest.

NB that if you have wine installed (in linux) you may need to run this command first to disable it (if you are building for a different architecture than the building machine, especially), so that it doesn't auto run files like conftest.exe, etc. during the build (they may crash with an annoying popup prompt otherwise) $ sudo update-binfmts --disable wine ref: http://askubuntu.com/questions/344088/how-to-ensure-wine-does-not-auto-run-exe-files

Feedback welcome roger-projects@googlegroups.com

Related projects (similar to this one...): https://github.com/jb-alvarado/media-autobuild_suite (native'ish windows using msys2) https://github.com/Warblefly/multimediaWin64 (native'ish windows using cygwin) there's also the "fast" option see above, within this project

Related projects (that do cross compiling with dependency libraries):

vlc has a "contribs" building (cross compiling) system for its dependencies: https://wiki.videolan.org/Win32Compile/ (NB this script has an option to compile VLC as well, though currently it makes huge .exe files :) mxe "m cross environment" https://github.com/mxe/mxe is a library for cross compiling many things, including FFmpeg I believe.

[1] if you use a 512MB RAM droplet, make sure to first add some extra swap space: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 before starting.
Here's my digitalocean referral link in case you want it [you get $10 free credit] https://www.digitalocean.com/?refcode=b3030b559d17

About

Helper script for cross compiling some media tools for windows, like customizable ffmpeg.exe (with or without fdk_aac), and other bonuses like mplayer, vlc, mp4box, mxf, etc.

License:GNU General Public License v3.0


Languages

Language:C++ 81.1%Language:Shell 16.8%Language:C 1.6%Language:Batchfile 0.5%