Add hybrid MP4 muxer for crash-safe recording with non-fragmented fin…#3152
Add hybrid MP4 muxer for crash-safe recording with non-fragmented fin…#3152anthonybajoua wants to merge 1 commit intoandroidx:releasefrom
Conversation
|
Hi @anthonybajoua, Thank you for putting together this PR. We would like to understand a bit more about the specific need for this feature. You mentioned that the main goal here is to keep the file readable for crash/fault tolerance. However, our normal MP4 files are already recoverable on a crash because our current implementation updates the You can find the documentation for this behavior in Could you take a look and let us know if using the existing Looking forward to your thoughts! |
|
Thanks for taking a look @shahdDaghash ! The specific use-case is long running video recording sessions that may encounter process crash, battery death.
In local testing, transcoding a 1GB file the file is the beginning it's viewable. Once the file becomes too large the mp4 format is as follows and unplayable. This transition happens around 20 minutes in Hybrid MP4 will not have this problem as the media is fragmented all the way through until a final pass at hiding the |
|
The amount of space reserved is configurable via an API on Mp4Muxer - do you have an estimate of how long the recording could be? Would a much larger amount of reserved bytes for moov work for your use case? |
|
@anthonybajoua I would like add some more details.
If the preallocated space is not enough, even then In your local testing do you not see a |
Summary:
Hybrid MP4 support involves ending up with a normal, non-fragmented file on happy path cases, while still keeping the file readable via its interim state as fragmented mp4 allowing for crash/fault tolerance.
See Writing an MP4 Muxer for fun and profit for more details.
Components:
HybridMp4Muxer / HybridMp4Writerare implementations of hybrid MP4 melding the currentFragmentedMp4Muxerwith some bookkeeping to convert it at the end.HybridMp4MuxerEndToEndTestwhich adds tests to the fault tolerance, as well as assertions of having no output.Credit
Inspired by FFmpeg-devel ingesting all of the optimizations from FFmpeg 8.1