Garbage collection free video pipelines with Kotlin and coroutines
summary
Kotlin coroutines and small, allocation-free abstractions produce a live Android pipeline that captures Camera2 frames, rotates them with RenderScript rotation, converts encoder output from Annex‑B (start codes) to AVCC with a NAL inline mapper, packages into FLV tags and publishes over RTMP using librtmp via the NDK. A timestamp delegate enforces monotonically increasing timestamps (a bug where timestamps ran ~10x too fast crashed a partner transcoder). The GCroid streamer is deployed in a production app and successfully streams with near‑zero GC and predictable camera state via suspendable flows.
AI-written summary · about
chapters (12)
- 0:00Introduction to mobile video streaming
- 1:58Understanding AAC audio format
- 3:00Deep dive into H.264 video format
- 9:41FLV container and RTMP basics
- 12:28Android video streaming pipeline
- 18:48Kotlin delegates and timestamps
- 23:02Inline functions for format conversion
- 27:42Augmenting bitstreams with SEI
- 31:34NDK and Java interop for RTMP
- 32:38Camera 2 API with coroutines
- 36:31Live demo and open source plans
- 37:15Q&A on streaming technologies
related talks
43mAndroid Jetpack ❤️ Kotlin: On the road to more wholesome APIs
55mIntro & Keynote
40mDeep diving into the Kotlin Coroutines API
40mBuilding Asynchronous Mechanisms in Android App, Using Kotlin Coroutines
01h 13mModern Android development
38mRendering Video: A Detailed Look at Video Playback on Android
38mUnderstand Kotlin Coroutines on Android
36mDeep Dive into Kotlin Flow Buffering and Execution Models Using Real-Time Audio Processing
