Running Real-ESRGAN and NAFNet on AndroidEngineering a 100% On-Device AI Video Upscaler — Zero Cloud Infrastructure

A technical breakdown of how OnDevice — Video Enhancer achieves deep-learning video super-resolution and motion deblurring locally on mobile GPUs and NPUs via ONNX Runtime Mobile — with zero cloud uploads and footage that is never sent to a server.

Introduction: The Cloud Paradigm vs. Edge Intelligence

State-of-the-art super-resolution networks like Real-ESRGAN and image restoration networks like NAFNet (Nonlinear Activation Free Network) have set the gold standard in computer vision. However, deploying these architectures for consumer mobile applications has historically relied almost exclusively on cloud servers.

The cloud paradigm carries massive trade-offs:

  1. Severe Privacy Hazards: Users must upload sensitive personal, family, and confidential recordings to remote cloud buckets. Footage is never truly private.
  2. Bandwidth & Latency Bottlenecks: Uploading and downloading multi-gigabyte video files over cellular data is slow and expensive.
  3. Escalating Cloud Costs: GPU compute hours on A100/H100 instances force cloud apps into exorbitant recurring subscription models ($9.99+/week). In contrast, local edge inference eliminates remote GPU costs entirely, making OnDevice 100% free with unlimited exports.

This article examines how OnDevice — Video Enhancer (com.nabil.ondevice.videoenhancer) bypasses the cloud entirely, deploying optimized ONNX neural models directly onto Android devices — running on consumer Qualcomm Snapdragon, MediaTek Dimensity, Samsung Exynos, and Google Tensor chipsets. Your footage is never sent to a server.

Architecture Overview

The on-device local pipeline is structured into four decoupled, memory-safe stages:

[ Input MP4 / MOV / MKV Video ]
           │
           ▼
┌────────────────────────────────────────┐
│ 1. Native MediaCodec Decoder Pipeline  │
│    Extracts raw RGB/YUV bitstream      │
└────────────────────────────────────────┘
           │
           ▼
┌────────────────────────────────────────┐
│ 2. Edge Neural Network Inference       │
│    • Real-ESRGAN Compact 4x (FP16)    │
│    • OpenCV NAFNet Deblur 1x           │
│    • MobileSR 2x (Fast Conv)           │
│    • AnimeSharp 2x (Line-Art)          │
│    • MobileClear (Laplacian DSP)       │
└────────────────────────────────────────┘
           │
           ▼
┌────────────────────────────────────────┐
│ 3. Foreground Service & Thermal Policy │
│    • Android Game Mode GPU Lock        │
│    • Chunked In-Memory Frame Buffer    │
└────────────────────────────────────────┘
           │
           ▼
┌────────────────────────────────────────┐
│ 4. Hardware Encoder & Muxer            │
│    • MediaMuxer + MediaCodec (H.264)   │
│    • Audio Stream Preservation         │
└────────────────────────────────────────┘
           │
           ▼
[ Output 2x / 4K Enhanced Video — local device storage only ]

At no stage in this pipeline is any video frame, metadata, or user data transmitted to an external server. The entire process — from frame decode to re-encode — occurs within your device's hardware boundary.

1. The Model Suite: Balancing Quality, Compute, and Footprint

A. Real-ESRGAN Cinematic 4x (Photorealistic Texture Synthesis)

B. OpenCV NAFNet Unblur & Restore 1x (Motion & Defocus Inversion)

C. MobileSR 2x (Ultra-Fast Lightweight Super-Resolution)

D. MobileClear Fast 1x (Native DSP Engine — Zero Download)

2. Solving Mobile Constraints: Memory, Thermal, and Throttling

Memory Management & OOM Prevention

A naive implementation might load multiple frames into a queue as uncompressed 32-bit bitmaps. A single 1080p frame consumes ~8.3 MB of RAM — buffering 60 frames would easily breach Android's per-app memory limit (256 MB–512 MB on standard devices).

Solution: OnDevice implements a strict backpressure pipeline. The decoder extracts a single frame, copies the normalized tensor directly into the ONNX Runtime input tensor, executes inference, and pipes the output directly to the hardware encoder's input surface before releasing the buffer. Peak RAM usage remains constant regardless of video duration — 10 seconds or 10 minutes.

Thermal Throttling & Android Game Mode

Long-running AI workloads cause mobile SoCs to heat up, triggering Android's thermal daemon to throttle CPU/GPU frequencies down to 30% of their base clocks — dramatically slowing frame processing speed.

Solution: The app implements the Android Game Mode API (android.game_mode_config) and utilizes foreground wake locks. By signaling the OS that the application is performing an intensive, continuous compute task, the scheduler prevents erratic frequency downscaling, ensuring consistent frame throughput across long export sessions.

3. Performance Benchmarks (On-Device)

All benchmarks run entirely on-device — footage never leaves the device boundary:

Device Chipset Tier Model Per-Frame Latency 10s / 30FPS Clip
Snapdragon 8 Gen 3 Flagship Real-ESRGAN Compact 4x ~85 ms ~25.5 seconds
Snapdragon 8 Gen 2 Flagship MobileSR 2x ~32 ms ~9.6 seconds
Dimensity 9200+ Flagship NAFNet Unblur 1x ~140 ms ~42.0 seconds
Snapdragon 778G Mid-Range MobileSR 2x ~65 ms ~19.5 seconds
Helio G99 / Budget Budget MobileClear DSP ~8 ms ~2.4 seconds

4. Why On-Device AI Is the Future of Mobile Multimedia

The success of OnDevice — Video Enhancer demonstrates that consumer mobile devices have reached the performance inflection point where desktop-class neural restoration models can run entirely locally.

By eliminating remote server infrastructure:

How to Try It

OnDevice — Video Enhancer is built using Kotlin, Jetpack Compose Material 3, and ONNX Runtime Mobile. Available on Google Play:

Try OnDevice — Video Enhancer

Real-ESRGAN + NAFNet running 100% locally on your Android. Footage never sent to a server. Free.

Download on Google Play