BitComet Android FFmpeg relinking kit, build-2
FFmpeg commit b4a62c32549b8295691a8e0ff2c9b82188923159
Media3 commit 8c6678b657ede1e7883fc164ef73ed483c7796c3
NDK 28.1.13356709, API 24, arm64-v8a and x86_64.

This kit contains the original non-FFmpeg JNI object for each ABI,
the corresponding FFmpeg static libraries, wrapper source, license texts,
the original AAR, and portable build/relink instructions.
Download ffmpeg-source.tar.xz separately from the source-version directory.
The version directory's SHA256SUMS covers the source archive and each build ZIP.
Before extraction, compare their SHA-256 values using Get-FileHash -Algorithm SHA256.
Paths in manifest.json refer to files inside this ZIP, relative to its root.
Retain all per-file copyright and license notices.
App version 3.2.1 uses this component build; future identical builds may reuse it.

1. Unpack ffmpeg-source.tar.xz. Make your changes in the FFmpeg source.
2. Install MSYS2 make, diffutils, coreutils and a host C compiler,
   plus Android NDK 28.1.13356709. In MSYS2 use:
   pacman -S --needed make diffutils coreutils mingw-w64-x86_64-gcc
   In MSYS2 Bash, run (adjust only your input paths):
   bash build-ffmpeg.sh /c/work/ffmpeg /c/Android/ndk/28.1.13356709 /c/work/rebuilt
3. In PowerShell, relink against your rebuilt libraries:
   powershell -ExecutionPolicy Bypass -File relink.ps1 -NdkPath C:\Android\ndk\28.1.13356709 -LibrariesPath C:\work\rebuilt\android-libs
   For the supplied original libraries, omit -LibrariesPath.
4. Replace jni/<abi>/libffmpegJNI.so in the supplied AAR with output/<abi>/libffmpegJNI.so.
   The Media3 Java interface and FFmpeg ABI must remain compatible.
5. To replace the libraries in an APK and sign with your own key, run:
   Install a JDK (17 or newer recommended) and set JAVA_HOME to its root.
   Both Windows PowerShell 5.1 and PowerShell 7 are supported.
   powershell -ExecutionPolicy Bypass -File replace-apk-library.ps1 -ApkPath C:\work\original.apk -LibrariesPath C:\work\output -BuildToolsPath C:\Android\build-tools\36.0.0 -KeyStorePath C:\work\user.keystore -KeyAlias user -OutputPath C:\work\modified.apk
   The script uses JDK jar with explicit ZIP Store, Android SDK zipalign
   and apksigner, prompts for the
   signing password, and verifies the resulting signature. It preserves
   the APK's existing ABI set and does not overwrite an existing output.
   All native-library ZIP headers, replacement SHA-256 hashes, signature
   and final 16-KiB ZIP alignment are checked before publishing the output.
   The output APK may be larger because entries are stored uncompressed.
   All file streams are closed before bounded-retry temporary-file cleanup;
   cleanup failure does not hide a primary signing or packing error.
   For automation, -PasswordEnvironmentVariable NAME reads the keystore
   password from that environment variable instead of prompting.
   Use adb install --no-incremental -r on a disposable emulator; stop the
   app before updating and allow startup to complete before sending input.
   Do not add a different ABI without all app libraries. The input APK's
   existing ABI set is preserved, regardless of its distribution variant.
   A different signing key prevents an update over the official installation.
   Test with a separate disposable emulator and preserve any user data.
   The official private signing key is not required or provided.
   Verify the signature with apksigner verify, then check logcat for the
   Media3 audio decoder initialized message while playing an AC-3/E-AC-3/DTS/TrueHD/AAC file.

6. Run powershell -ExecutionPolicy Bypass -File verify-materials.ps1
   after extraction to verify component files against manifest.json.
   This check does not require the external SHA256SUMS file.

7. Optional regression test (uses the public Android debug test key only):
   powershell -ExecutionPolicy Bypass -File replace-apk-library.test.ps1 -ScriptPath .\replace-apk-library.ps1 -ApkPath C:\work\debug.apk -LibrariesPath C:\work\output
   Run the same command with pwsh to test PowerShell 7. The test requires
   JAVA_HOME, Android SDK build-tools 36.0.0 and a local debug.keystore;
   BuildToolsPath and KeyStorePath may be supplied explicitly.
   It tests Store headers, output preservation, missing libraries,
   signing failure, missing FFmpeg and temporary-directory cleanup.
   It never installs an APK or deletes application data.

Pre-release material correction, 2026-10-18: the build-2 replacement script
now uses JDK jar instead of .NET NoCompression, whose ZIP method differed
between PowerShell runtimes. The AAR, JNI objects and FFmpeg static libraries
are unchanged. See manifest.json for this material revision and validation.

APK replacement/installation and the modified-library playback workflow
must be independently validated before release. This kit does not itself
claim that all distribution and license conditions have been approved.
LGPL permits modification for the user's own use and reverse engineering
for debugging those modifications. Third-party licenses take precedence
over conflicting general distribution terms.

Build-2 enables only ac3, eac3, dca (DTS), truehd and aac decoders.
No video decoders, GPL, nonfree or external codec libraries are enabled.
TrueHD is decoded as channel-based PCM; Atmos object rendering is not provided.
DTS Express and all DTS-HD variants are not individually certified by this kit.
See build-records for exact generated configuration and toolchain records.
