Repository navigation
Architecture
nomercy-ffmpeg builds FFmpeg 9.1 for seven platforms from one repository. Every build runs inside Docker. This page shows how the pieces fit.
| Layer | File | What it does |
|---|---|---|
| Base image | ffmpeg-base.dockerfile |
Holds the toolchains and the cross compilers. Sets the version of every bundled library. Downloads the sources into /build. |
| Platform image | ffmpeg-<platform>.dockerfile |
Sets the target (TARGET_OS, ARCH, compiler and flags). Runs the numbered steps. Configures and builds FFmpeg. Packs the archive. |
| Final stage | the last FROM alpine in each platform file |
Holds only the archive. Its command copies the archive to /output. |
The platforms are linux-x86_64, linux-aarch64, windows-x86_64, windows-aarch64, darwin-x86_64, darwin-arm64 and freebsd-x86_64. All of them build on the same base image. See Platforms for what each one needs at run time.
The folder scripts/ holds one script per library or custom patch. The number sets the order.
scripts/03-zlib.sh
scripts/48-whisper.sh
scripts/57-hls-master-playlist.sh
scripts/66-lyricsalign.sh
scripts/init/init.sh runs them in order. It treats the exit code like this.
| Exit code | Meaning |
|---|---|
0 |
The step built. |
255 |
The step does not apply to this target. It is skipped. |
| anything else | The build stops. The last 200 lines of the step's log are printed. |
A failed step fails the build. FFmpeg is never configured without a component that was meant to be in it.
Each step uses small helpers from scripts/init/helpers.sh.
| Helper | What it does |
|---|---|
add_enable |
Adds a --enable-... flag to the FFmpeg configure line. |
add_cflag, add_ldflag
|
Adds a compiler or linker flag. |
add_extralib |
Adds a library to the final link. |
log |
Writes to the step's log. |
After the last step, the platform file runs ./configure with every collected --enable flag, builds FFmpeg, and calls scripts/init/package.sh. That script copies ffmpeg and ffprobe (and ffplay when it exists), puts the espeak-ng-data/ folder next to them, signs the binary on macOS, and writes ffmpeg-9.1-<platform>.tar.gz or .zip.
Three folders hold steps for one target only.
| Folder | Used when |
|---|---|
scripts/includes/darwin/ |
TARGET_OS is darwin. |
scripts/includes/windows/ |
TARGET_OS is windows. |
scripts/includes/linux/ |
any other target (currently empty). |
init.sh copies those scripts into /scripts/ before it runs the steps. A script with the same name as a shared step replaces it for that target. Example: scripts/includes/darwin/50-librsvg.sh replaces scripts/50-librsvg.sh on macOS.
| Kind | Examples | Used for |
|---|---|---|
| FFmpeg source we add |
vobsubenc.c, spritevttenc.c, chaptervttenc.c, dvdread_proto.c
|
New muxers, encoders and a protocol. See Muxer-VOBsub, Muxer-Sprite-Sheet, Muxer-Chapter-VTT and Protocol-dvdread. |
| Whole-file copies of FFmpeg files |
hlsenc.c, codecstring.c, hlsplaylist.c, hlsplaylist.h, af_whisper.c
|
Replace the upstream file at build time. See Adding or Updating a Library. |
| Patches | *.patch |
Changes to a library we do not own. |
| Filter sources |
af_lyricsalign.c, af_trailingsilence.c, nm_*.h
|
Our own filters. See Filter-lyricsalign and Filter-trailingsilence. |
| Link and runtime scripts |
linux_link.sh, verify_linux_runtime.sh
|
Link rules and checks on the finished binary. |
Some filters come from their own projects and are fetched at build time, pinned to a release: stemsplit, keydetect and beatdetect. ffmpeg -h filter=stemsplit prints the version in a build. See Filter-stemsplit, Filter-keydetect and Filter-beatdetect.
Release tarballs are fetched with fetch-pinned, a helper defined in ffmpeg-base.dockerfile. It takes a file name, a SHA-256 and a list of URLs.
- It tries the first URL, up to three times.
- It computes the SHA-256 of what came back.
- A file with the wrong digest is deleted and the next URL is tried.
- If no URL serves a matching file, the build fails.
The first URL is a pinned source mirror. The next URLs are the upstream origin. So a mirror that is down or not filled yet does not stop a build, and a changed file never gets through.
Libraries that are built from a git tag are pinned to that tag instead.
| Part | Where |
|---|---|
| Test scripts |
tests/. See Testing. |
| Workflows |
.github/workflows/. See CI and Releases. |
| Local build |
docker-compose.yml. See Building Locally. |
| npm client |
clients/npm/. See npm-Package. |
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors