Building EyeMax: Live Cinema Aspect Ratio Crops on Android
Cinema aspect ratios get talked about as trivia: IMAX is taller, CinemaScope is wider, Academy is squarer. What gets lost is that each one is a real crop of the frame. If you watch a 16:9 video and want to know what 2.39:1 would actually keep, you have to do the arithmetic and imagine it. I wanted an app that shows it directly, on any video, while it plays. That is EyeMax, an Android video player I built in Kotlin.
Why I built it
I wanted to compare formats on the same footage without exporting a new file each time. Editing tools can do it, but they involve re-encoding and a round trip for every comparison. The goal was simpler: pick a video, tap a format, see the crop immediately, tap another, and keep playing. No reload, no stutter, no re-encode.
What it does
EyeMax plays a local video file or a YouTube link. For local files you can pick from storage, or open and share a video into the app from Files, a gallery or another app. You then switch between 11 theatrical and broadcast aspect ratios during playback, plus an Original mode that shows the source uncropped.
- 1.19:1 Movietone (late 1920s)
- 1.37:1 Academy (1930s to 1950s)
- 1.43:1 IMAX GT (1970s to today)
- 1.66:1 Euro Flat
- 1.85:1 35mm Flat
- 1.90:1 IMAX Digital
- 2.20:1 70mm
- 2.39:1 35mm Scope
- 2.55:1 CinemaScope
- 2.59:1 Cinerama
- 2.76:1 Ultra Panavision 70
Each format retains exactly the share of the frame it should. On a 16:9 source, 1.43:1 keeps 80% of the frame, 1.37:1 keeps 77%, and 2.39:1 keeps 74%. The app derives these numbers from the real source and target ratios instead of storing them as constants.
How it works
The stack is Kotlin and Jetpack Compose in a single Activity. Local playback uses Media3 ExoPlayer. YouTube playback uses the android-youtube-player library, which wraps the IFrame Player API. There is no backend and no analytics; local files are read by the device and never leave it.
The crop rule
The core logic lives in AspectCrop.kt and is two pure functions with no Android dependencies:
computeCrop(sourceAspect, targetAspect)finds the largest centered window of the source that matches the target ratio exactly. If the source is wider than the target, it trims left and right. If it is narrower, it trims top and bottom.fitWithin(aspect, maxWidth, maxHeight)sizes the display box to the target ratio (or the source ratio for Original), fitted inside the available screen space.
The second function matters more than it looks. The display box is never stretched to fill a screen of a different shape. If it were, the visible area would no longer match the format, and the percentage on the label would be wrong. Letterboxing is the honest result.
Applying it without reloading
The crop is applied as a graphicsLayer scale on the video surface that already exists. Nothing is re-rendered, re-encoded or reloaded, which is why switching formats mid-playback is instant. The same rule drives both playback paths. Local files go through ExoVideoStage.kt, where the surface is a PlayerView. YouTube goes through YouTubeVideoStage.kt, where it is a WebView. Both are ordinary Android Views, so the same crop and scale treatment works on either.
Keeping the UI out of the way
The top bar, format selector and transport controls hide themselves 3 seconds after they appear, and a tap on the video brings them back. The format selector is a scrollable strip docked on the right, with insets padding so it clears the status bar, gesture navigation area and any on-screen dock.
What I learned
- Do not stack corrections. An earlier version added a fill-the-screen zoom on top of each format's own crop. That could trim more than the selected ratio defines, so the percentages were off. Removing it and letting the box be the target ratio fixed the problem. If a number is displayed to the user, there should be one place that produces it.
- Keep the math pure. Because the crop functions have no Android dependencies, they are easy to reason about and to check by hand against known values like 80%, 77% and 74%.
- Crop the view, not the media. Treating both players as Views and scaling them with one mechanism avoided writing two crop implementations.
- Layout details need real devices. The format selector overlapped the navigation area on a phone until I added proper insets handling.
There are limits I should state plainly. Local format support is whatever the device's MediaCodec supports, which covers MP4, MKV, WebM and most common codecs, but not every video format. The YouTube path assumes a 16:9 source because the IFrame Player API does not expose the video's real intrinsic size, so crops on non-16:9 YouTube videos will not be exact.
Conclusion
EyeMax came out of one small idea: a cinema format is a crop, so compute the crop honestly and apply it cheaply. The result is a short crop function, a fit function, and a scale on a surface that is already playing. The source and a v1.0.0 debug APK are on GitHub, and the APK is on the release page. Since it is a debug build, Android will show an unverified app warning when you install it.