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:
In some type of Linux box (VM or native, or you can create a remote one temporarily, like at digitalocean [1], use it, then destroy it):
download the script (git clone the repo, run it, or do the following in a bash window) $
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
./cross_compile_ffmpeg.sh
And follow the prompts.
It should end up with a working static ffmpeg.exe within the sandbox directory.
It works with 32 or 64 bit (host) Linux, and can produce either/or 32 and 64 bit windows ffmpeg.exe's, with lots of dependencies built in. To build more than just FFmpeg, use command line parameters to the script.
OS X users, this may help: https://github.com/rdp/ffmpeg-windows-build-helpers/wiki/OS-X
Also NB that it has some command line parameters you can pass it, for instance to speed up the building speed of gcc, building a shared build (.dll style) of FFmpeg, etc. Run it like ./cross_compile_ffmpeg.sh -h to see all the various options available to you.
If you want to customize your FFmpeg final executable even more (remove features you don't need, etc.) then edit the script
- 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.
- Remove or add the # to the lines you're enabling or disabling in the build_dependencies() function
- 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
- There are some helper method do_XXX etc. for checking out code, running make, etc. that may be useful.
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.
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 (at least if you're using libx264) doesn't end up helping much (it might make a smaller executable?) since libx264 auto detects and auto uses your cpu capabilities anyway, so...until further research is done, this option may not provide significant speedup. Ping me if you get different results than this.
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 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 will 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 NB that using a -march might not significantly improve speed [YMMV], ping me if you want even more aggressive optimization possibilities, I may be able to come up with a few more.
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)
ping me if you want this script ported to more native as well :)
vlc has a "contribs" building (cross compiling) system for its dependencies: https://wiki.videolan.org/Win32Compile/
mxe "m cross environment" https://github.com/mxe/mxe is a library for cross compiling many things.
https://github.com/qyot27/mpv/blob/extra-new/DOCS/crosscompile-mingw-tedious.txt lists lots of instructions
[1] if you use a 512MB RAM droplet, make sure to 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 [$10 credit] https://www.digitalocean.com/?refcode=b3030b559d17