video_normalizer_android

The Android implementation of video_normalizer. Apps depend on video_normalizer; this package is endorsed and comes with it.

What it is made of

Engine Jetpack Media3 Transformer 1.11.1 (media3-transformer, media3-effect, media3-common)
Language and build Kotlin, Gradle Kotlin DSL, Java 17 source and target level
minSdk / compileSdk 24 / 36
Native libraries none
Permissions none
Channel generated by Pigeon from the platform interface's pigeons/messages.dart; no hand-written channel code

The Gradle script works with AGP 9's built-in Kotlin and with the Kotlin Gradle Plugin, never applies Kotlin twice and never names a Kotlin version. See docs/ANDROID_BUILD.md for the consumer configurations that were built.

How a job runs

JobRegistry is process-wide, so jobs outlive the Flutter engine that started them and several engines can share it. One HandlerThread runs every job's state machine and is the looper Media3 is bound to.

  1. MediaAnalyzer reads the source with MediaExtractor and a small MP4 box scanner: nothing is decoded.
  2. EncoderSettingsVerifier confirms the resolved settings against the device's encoders (MediaCodecList) before anything is decoded. The encoder it picked is the encoder Media3 is given.
  3. TransformerEngine builds the Media3 export: scaling, frame-rate reduction, HDR tone mapping, audio mix-down, metadata filtering. Encoder and format fallbacks are switched off.
  4. FastStartRelocator moves the MP4 index to the front of the file, in place.
  5. OutputValidator reopens the file and compares it with what was asked for. Only then does the file get its final name.

A failure at any step deletes the partial file and reaches Dart as one of the codes in docs/ERRORS.md.

Status

Integration tested on emulators (API 34; the release build also on API 35 with 16 KB pages). Not tested on physical devices. HDR tone mapping could not be run on an emulator at all. Details: docs/COMPATIBILITY.md.

Working on it

# unit tests (JVM)
cd packages/video_normalizer/example/android
gradlew :video_normalizer_android:testDebugUnitTest

# lint
cd packages/video_normalizer_android/android
java -jar ktlint-cli-1.8.0-all.jar "src/**/*.kt" "*.kts"

# everything on a device
tool\run_android_integration.ps1

Libraries

video_normalizer_android
The Android implementation of the video_normalizer plugin.