Convert Figma logo to code with AI

rdp logoffmpeg-windows-build-helpers

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

1,074
411
1,074
49

Top Related Projects

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.

Quick Overview

The rdp/ffmpeg-windows-build-helpers repository is a collection of scripts and tools that simplify the process of building FFmpeg on Windows. FFmpeg is a popular multimedia framework used for video and audio processing, and this project aims to streamline the often complex build process on the Windows platform.

Pros

  • Automated Build Process: The scripts in this repository handle the entire build process, from downloading dependencies to compiling FFmpeg, making it easier for developers to get started.
  • Customizable Configurations: The project allows users to customize the build configuration, including the selection of FFmpeg components and the target architecture.
  • Comprehensive Documentation: The repository includes detailed documentation, providing guidance on installation, usage, and troubleshooting.
  • Community Support: The project has an active community, with contributors addressing issues and providing assistance to users.

Cons

  • Windows-specific: The project is focused on building FFmpeg on Windows, which may limit its usefulness for developers working on other platforms.
  • Dependency on External Tools: The build process relies on external tools, such as MSYS2 and CMake, which adds complexity and potential points of failure.
  • Outdated Dependencies: Some of the dependencies used in the project may become outdated over time, requiring manual updates to maintain compatibility.
  • Limited Flexibility: While the project offers some customization options, the overall build process may not be as flexible as building FFmpeg from scratch.

Getting Started

To get started with the rdp/ffmpeg-windows-build-helpers project, follow these steps:

  1. Clone the repository:
git clone https://github.com/rdp/ffmpeg-windows-build-helpers.git
  1. Navigate to the project directory:
cd ffmpeg-windows-build-helpers
  1. Run the build script:
./build_ffmpeg.sh

This script will download the necessary dependencies, configure the build, and compile FFmpeg. The resulting binaries will be placed in the ffmpeg_git/bin directory.

  1. (Optional) Customize the build configuration by editing the build_options.sh file. This file allows you to specify the FFmpeg components to include, the target architecture, and other build settings.

Competitor Comparisons

Pros of FFmpeg-Builds

  • Provides pre-built FFmpeg binaries for multiple platforms (Windows, macOS, Linux)
  • Offers both release and development builds with various configurations
  • Automated build process with GitHub Actions for frequent updates

Cons of FFmpeg-Builds

  • Limited customization options for end-users
  • May not include all possible FFmpeg configurations or libraries
  • Lacks detailed documentation on build process and included features

Code Comparison

FFmpeg-Builds uses GitHub Actions for automation:

jobs:
  build_ffmpeg:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]

ffmpeg-windows-build-helpers uses shell scripts for building:

#!/usr/bin/env bash
set -e
./cross_compile_ffmpeg.sh --build-ffmpeg-shared=y --build-intel-qsv=y

Both projects aim to simplify FFmpeg compilation, but FFmpeg-Builds focuses on providing ready-to-use binaries across multiple platforms, while ffmpeg-windows-build-helpers offers more flexibility for custom Windows builds. FFmpeg-Builds may be more suitable for users who need quick access to pre-built binaries, while ffmpeg-windows-build-helpers is better for those requiring specific configurations or libraries on Windows.

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.

Pros of media-autobuild_suite

  • More comprehensive build options, including support for a wider range of media tools and libraries
  • Better customization options for building specific components
  • More frequent updates and active community support

Cons of media-autobuild_suite

  • More complex setup and configuration process
  • Longer build times due to the inclusion of additional components
  • Steeper learning curve for new users

Code Comparison

media-autobuild_suite:

set MSYSTEM=MINGW64
set MINGW_INSTALLS=mingw64
set BUILD_EXTRAS=y
set COMPILE_FFMPEG=y
set COMPILE_LIBASS=y

ffmpeg-windows-build-helpers:

./cross_compile_ffmpeg.sh --enable-gpl --enable-version3 --enable-nonfree

The media-autobuild_suite code snippet shows more granular control over the build process, allowing users to specify individual components and build options. In contrast, the ffmpeg-windows-build-helpers code is simpler but offers less customization.

media-autobuild_suite provides a more comprehensive solution for building media tools on Windows, with greater flexibility and options. However, it comes at the cost of increased complexity and longer build times. ffmpeg-windows-build-helpers offers a simpler, more focused approach specifically for FFmpeg, which may be preferable for users who don't need the additional features provided by media-autobuild_suite.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ffmpeg-windows-build-helpers

This helper script lets you cross compile a windows-based 32 or 64-bit version of ffmpeg.exe/mplayer/mp4box.exe, etc, including their dependencies and libraries that they use. Note that I do offer custom builds, price negotiable. Ping me at rogerdpack@gmail.com and we can negotiate, I'll do the work for you :)

The script allows the user to build using a Linux host (which uses cross compiles to build windows binaries). Windows users can use wsl or virtualbox (which run linux). Building on native linux box might take less time overall. NB if you use WSL Ubuntu 20.04 you need to do an extra step: https://github.com/rdp/ffmpeg-windows-build-helpers/issues/452 or look in the "extra" directory for a script to do various builds on WSL.

Cross-compiling from a Linux environment:

Takes about 2 hours.

Deploy a Linux VM on the host of your choice (>= 20.04 for Ubuntu), or natively on an extra computer or a dual boot system, or via a hosting provider such as Digital Ocean. Cheapest way: install windows 10 wsl bash shell. Another option: linux on a virtualbox VM. Another option, typically fast: temporarily rent a box (ex: DigitalOcean or vultr).

Download the script by cloning this repository via git:

$ git clone https://github.com/rdp/ffmpeg-windows-build-helpers.git
$ cd ffmpeg-windows-build-helpers

Now run the script:

$ ./cross_compile_ffmpeg.sh

Answer the prompts. It should end up with a working, statically-built ffmpeg.exe binary within the "sandbox/*/ffmpeg_git" director(ies). You're done!

If you're on a "too old" version of linux (or a distro besides Ubuntu, which is the most supported) you may have luck with building it inside a "docker" see the docker directory.

Another option which might save time (but doesn't have as many options, just creates an ffmpeg/x264/fdk-aac) instead of running ./cross_compile_ffmpeg.sh is to run

$ quick_build/quick_cross_compile_ffmpeg_fdk_aac_and_x264_using_packaged_mingw64.sh

script. Note the "quick" part here which attempts to use the locally installed mingw-w64 package from your distribution for the cross compiler, thus skipping the time-intensive cross-compiler toolchain build step. It's not as well tested as running the normal one, however, which builds gcc from scratch.

For Mac OSX users, simply follow the instructions for Linux above and built it natively in OS X terminal.

To view additional arguments and options supported by the script, run:

./cross_compile_ffmpeg.sh -h 

to see all the various options available.

For long running builds, do run them overnight as they take a while. You can just let it go...

If you want to build a "shared" build (there's a command line option for that :) then link it into your MSVC project see https://stackoverflow.com/questions/11701635/use-ffmpeg-in-visual-studio/11701737

Also note that you can also "cross compile" mp4box, mplayer,mencoder and vlc binaries if you pass in the appropriate command line parameters. And a few others. Some of them are currently broken, send a PM if you'd want it fixed.

To enable Intel QuickSync encoders (supported on Windows vista and above), which is optional, pass the option --build-intel-qsv=y to the cross-compilation script above. There is also an LGPL command line option for those that want that.

If you want to customize your FFmpeg final executable even further ( to remove features you don't need, make a smaller build, or custom build, etc.) then edit the script.

  1. Add or remove the "--enable-xxx" settings in the build_ffmpeg function (under config_options) near the bottom of the script. This can enable or disable parts of FFmpeg to suit your requirements.

You may also add new dependencies and libraries to the project as shown:

  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" parameter switches to the build_ffmpeg() function under the config_options.
  2. There are some helper methods (quoted under do_XXX clauses. for checking out code, running make only once, etc. that may be useful.

Note that you can optionally create a machine-optimized build by passing additional arguments to the --cflags parameter, such as --cflags='-march=athlon64-sse2 -O3' , as inferred by mtune. Google mtune options for references to this. A good reference can be found on Gentoo's wiki. Take precautions not to use excessive flags without understanding their impact on performance.

One option you cannot use is --cflags=-march=native (the native flag doesn't work in cross compiler environments). To find an appropriate "native" flag for your local box, do as illustrated here:

On the target machine,run:

% gcc -march=native -Q --help=target | grep march
-march=                               core-avx-i

Then use the output shown (in this case, core-avx-i, corresponding to Intel's Sandy-bridge micro-architecture) on the build machine:

% gcc -march=core-avx-i ...

Benchmarks prove 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 or any speedup, while making the executable "undistributable" since it can only be run on certain cpu's, but it's fun! Ping me if you get different results than this, as you may be wasting your time using the --cflags= parameter here.

Note that the build scripts fetch stable sources (not mainline) which may contain slightly older/out of date dependency versions, and as such, there may be implied security risks (see CVEs that may not be patched downstream), though FFmpeg itself will be built from git master by default.

Note 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 -march=XX 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

See this reference on the issue highlighted above. Failure to apply the workaround will most likely result in hangs (especially during the configure stage) as highlighted in the reference above.

Feedback is welcome, send an email to 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 vultr referral link in case you want it [you get $100 free credit] https://www.vultr.com/?ref=8518257-6G