Mimar Logics
All posts
March 14, 2026 · 8 min read

Android camera streaming: pitfalls we hit

AndroidMobileStreaming
Streaming the camera over RTSP from a stock Android phone sounds like a solved problem until you actually try it.
The first surprise was that CameraX abstractions hide where copies happen. Encoding to H.264 needs the YUV planes laid out a specific way, and naive bridging from Image to MediaCodec input dropped frames at higher resolutions.
The second was background behavior. Without a foreground service the OS will silently throttle network and CPU, breaking the stream the moment the screen turns off.
The fix was a dedicated foreground service that owns the encoder pipeline and exposes a notification with stream stats so the user knows it is running.
← Back to all posts