Hybrid MP4 Support
This release is the culmination of several recording pipeline improvements developed for FadCam. Building on previous Media3 patches for callback-based fragment delivery, HLS streaming, asynchronous fragment writing, and muxer reliability, this update introduces Hybrid MP4.
Hybrid MP4 automatically finalizes recordings as standard MP4 on a clean stop while preserving the crash-safe benefits of fragmented MP4 throughout recording.
Highlights
- Records as crash-safe fragmented MP4 during capture.
- Automatically finalizes the same file as a standard MP4 when recording stops normally.
- No video re-encoding.
- No duplicate output file.
- No media data copying.
- If recording is interrupted unexpectedly, the file remains a valid fragmented MP4 with all previously written media preserved.
Implementation
This patch extends the AndroidX Media3 fragmented MP4 muxer by:
- Adding a lightweight placeholder box that is patched during finalization.
- Generating a complete standard
moovbox with accurate sample tables after recording finishes. - Automatically selecting 32-bit (
stco) or 64-bit (co64) chunk offsets based on the final file size for maximum compatibility. - Preserving the existing fragmented MP4 recording workflow while seamlessly producing a standards-compliant MP4 on clean shutdown.
This implementation adapts the Hybrid MP4 concept for AndroidX Media3, inspired by the Hybrid MP4 approach introduced by OBS Studio.
Credits
Special thanks to the projects and contributors whose work helped make this possible:
- Albin Råstander (@albrast) for the original Media3 live fragmented muxer work, introducing callback-based fragment delivery and streaming-oriented improvements that became the foundation of this fork.
- OBS Studio for pioneering the Hybrid MP4 approach that inspired this implementation.
- AndroidX Media3 for the underlying muxer implementation extended by this project.
References
- OBS Studio Hybrid MP4: https://obsproject.com/blog/obs-studio-hybrid-mp4
- Original live fragmented muxer work: https://github.com/albrast/media/tree/feat/live-fragmented-muxer
- FadCam Hybrid MP4 design notes: https://github.com/anonfaded/FadCam/wiki/Hybrid-MP4