video_normalizer_ios

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

Status: implemented, never compiled or run. This code was written on Windows against Apple's documentation. Until someone has worked through docs/handoff/IOS.md on a Mac, treat it as unverified, and expect the first build to need small fixes.

What it is made of

Engine AVFoundation: AVAssetReader + AVAssetWriter to transcode, AVAssetExportSession (pass-through) to remux
Language Swift, tools version 5.9
Minimum iOS 15.0
Integration Swift Package Manager (ios/video_normalizer_ios/Package.swift); a CocoaPods podspec is provided as well
Third-party dependencies none
Permissions none. Videos come from a picker, which grants access to what the user chose
Privacy manifest PrivacyInfo.xcprivacy: no tracking, no collected data; one required-reason API (free disk space, reason E174.1)
Channel generated by Pigeon from the same pigeons/messages.dart as Android

How a job runs

JobRegistry is process-wide, so jobs outlive the Flutter engine that started them. Each job has its own serial queue.

  1. MediaAnalyzer reads the source with AVURLAsset and a Swift port of the Android box scanner: nothing is decoded.
  2. EncoderSettings builds the writer's settings from the job the Dart side resolved, and AVAssetWriter.canApply confirms them before anything is decoded.
  3. AssetTranscoder reads through a video composition that turns the picture upright, scales it and renders in BT.709 (which is also the HDR to SDR step), drops frames when the frame rate is reduced, and writes H.264 and AAC-LC with the index at the front of the file. PassthroughRemuxer copies compliant streams instead.
  4. 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.

Differences from Android

  • WebM and Matroska sources fail with unsupported_container: AVFoundation does not read them.
  • There is no content:// input; pass a path or a file:// URL. Security scoped URLs from the document picker are supported.
  • HDR conversion is reported as supported on every device, so HdrFallback.passThrough never comes into play.
  • capabilities() knows the encoders' names, not their limits.

The full comparison is in docs/handoff/IOS.md.

Tests

38 XCTest methods in packages/video_normalizer/example/ios/RunnerTests/RunnerTests.swift, and the same Dart integration suite that runs on Android. Neither has been run; the handoff document has the commands.

Libraries

video_normalizer_ios
The iOS implementation of the video_normalizer plugin.