# Media helper for OMNIvour for Mac (FFmpeg + LAME, LGPL)

Decision D2 (2026-10-28): bundle FFmpeg on desktop, LGPL only, H.264/HEVC/AAC encoded by the OS,
run as a sandboxed helper process, pinned with a review cadence. Decision 2026-11-02: LAME for MP3;
WebM and OGG outputs stay cloud-only (no libvpx/libvorbis).

## What gets built

`sh build.sh` (about 3 minutes on an M1 Max) downloads the pinned tarballs from `versions.env`,
checks their SHA-256, and builds for arm64 and x86_64:

- `dist/Frameworks/`: libavcodec, libavformat, libavutil, libavfilter, libswscale, libswresample,
  libmp3lame as universal shared libraries with `@rpath` install names (replaceable, as the LGPL asks).
- `dist/MacOS/ffmpeg`, `dist/MacOS/ffprobe`: universal helpers with `LC_RPATH
  @executable_path/../Frameworks`, signed ad hoc with `inherit.entitlements` (app-sandbox + inherit:
  they run inside the app's sandbox, as its children). Xcode re-signs them with the team identity.
- `dist/MANIFEST.json`: versions, per-file SHA-256, architectures, sizes, toolchain.

`--disable-everything` plus explicit lists keeps only the demuxers, muxers, codecs and filters the
app uses. `--disable-autodetect` keeps anything from Homebrew (x265 is installed on the build Mac)
out of the build. `--disable-network` removes network protocols entirely.

The build aborts unless: `ffmpeg -L` says GNU Lesser General Public License; no
`--enable-gpl|nonfree|version3` in the build configuration; `h264_videotoolbox`,
`hevc_videotoolbox`, `aac_at` and `libmp3lame` are present and `libx264|libx265|libfdk_aac` are not;
every file is universal; nothing links outside `/usr/lib`, `/System/Library` or `@rpath`.

Notes from the first build (2026-11-02):
- The self-checks run before signing: with the hardened runtime an ad hoc signed executable refuses
  ad hoc dylibs ("different Team IDs"), and an executable carrying `inherit` only runs as the child
  of a sandboxed app, so neither can be run from Terminal once signed.
- x86_64 is built with `--disable-x86asm` (no nasm on the build Mac); VideoToolbox does the heavy
  encoding. The x86_64 slice is inspected, not executed (no Rosetta on this Mac).
- LAME 4.0's configure wants pkg-config even with its frontend off; a stand-in that finds no optional
  libraries keeps the build free of Homebrew tools.

## Bumping a version (quarterly review; next 2027-02-01)

1. Change the version, URL and SHA-256 in `versions.env` together (cross-check the hash against a
   second source, for example the Homebrew formula, or verify the upstream `.asc` signature).
2. `sh build.sh`, then `cp dist/MANIFEST.json MANIFEST.json`.
3. Update `THIRD_PARTY_NOTICES.md`, and `apps/macos/project.yml` if any library soname changed.
4. Run the real-conversion proof in `apps/macos/README.md` and the gates.

`dist/` is gitignored: the binaries are rebuilt from this recipe, and `MANIFEST.json` pins them
(`apps/apple/gates/macos-ffmpeg.sh` checks `dist/` against it when present).
