# Minimal LGPL FFmpeg for EPUB Reader's audiobook export

`build-ffmpeg.sh` builds a small, statically linked, LGPL-2.1-or-later `ffmpeg.exe` (Windows x64; ARM64 Windows runs it
under emulation, as Audio Converter does) into `tools/bin/ffmpeg/` (gitignored). It is the Audio Converter recipe
(`audio-converter/tools/ffmpeg/`, same FFmpeg tag `n9.0.2` and MSYS2 pins) with only what the export needs:

- in: float samples piped per chapter (f32le), encoded to ADTS AAC or MP3, then piped back to back into the `aac` / `mp3`
  demuxer and joined by stream copy (the `concat` demuxer guesses ADTS lengths and leaves gaps); chapters and tags from an `ffmetadata` file; a PNG or
  JPEG cover (stream-copied);
- out: AAC in M4B (`ipod` muxer, QuickTime chapter track) or MP3 with LAME (`mp3` muxer, ID3v2 CHAP frames and APIC).

Run from an MSYS2 MINGW64 shell: `SKIP_PACMAN=1 bash tools/ffmpeg/build-ffmpeg.sh` (about 3 minutes).
The script refuses a non-LGPL configuration and any import that is not a Windows system DLL, and writes
`LICENSE.txt`, `SOURCE.txt` (source offer: tag, commit, URLs, configure line) and `buildconf.txt` next to the exe.

Result 2026-10-17: `ffmpeg.exe` 3,183,616 bytes; imports bcrypt, KERNEL32, msvcrt, SHELL32 only. Checked with
Audio Converter's ffprobe: an M4B and an MP3 made from two WAVs carry both chapters with their titles (Unicode kept)
and the cover as an attached picture.
