Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Last active September 4, 2020 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslushnikov/2f07c6219e4d2b02b99f77edd6b7cb12 to your computer and use it in GitHub Desktop.
Save aslushnikov/2f07c6219e4d2b02b99f77edd6b7cb12 to your computer and use it in GitHub Desktop.
cross-compiling ffmpeg for windows

[FAILED] Cross-compiling ffmpeg for Windows

UPDATE: this attempt failed :( Resulting binary doesn't support vp8 encoding.

I tried cross-compiling ffmpeg for windows on Sep 1, 2020 Cross-compiling ffmpeg for Windows seems to be very plausible, according to the documentation at https://trac.ffmpeg.org/wiki/CompilationGuide/CrossCompilingForWindows

I decided to use https://github.com/rdp/ffmpeg-windows-build-helpers. I tried using it on Mac 10.15, but unfortunately it failed for me.

So I decided to run inside Ubuntu 18.04 docker image: docker run --rm -it ubuntu-18.04 /bin/bash. All the following steps are happenning inside docker:

  1. Install all required packages to bootstrape bare ubuntu-18.04. These include git, ssh and vim - to live inside, and also a bunch of packages required to cross-compile ffmpeg.
$ sudo apt-get install -y git ssh vim python3-setuptools lsb_release cmake python clang meson autogen gperf nasm unzip pax mercurial ed g++ texinfo bison flex cvs yasm automake autoconf gcc subversion make pkg-config curl ragel
  1. Get latest meson (as described at rdp/ffmpeg-windows-build-helpers#429 (comment))
~$ git clone https://github.com/mesonbuild/meson.git
~$ ln -s /root/meson/meson.py /usr/local/bin/meson
  1. Clone repository
~$ git clone https://github.com/rdp/ffmpeg-windows-build-helpers
  1. Change configuration options: edit cross_compile_ffmpeg.sh and find line that starts with config_options="$init_options. (this is line 2323 for me). Change the line into the following:
config_options="$init_options --disable-everything --enable-ffmpeg --enable-protocol=pipe --enable-protocol=file --enable-parser=mjpeg --enable-decoder=mjpeg --enable-demuxer=image2pipe --enable-filter=pad --enable-filter=crop --enable-filter=scale --enable-muxer=webm --enable-encoder=libvpx_vp8 --enable-libvpx --enable-static"
  1. As of September 2, 2020, LAME doesn't trans-compile: rdp/ffmpeg-windows-build-helpers#485

However, since we don't need it for FFMPEG, comment out the build_lame function in cross_compile_ffmpeg.sh.

  1. Run the script passing the release version:
~ffmpeg-windows-build-helpers$ ./cross_compile_ffmpeg.sh --ffmpeg-git-checkout-version=n4.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment