Search code examples
androidkotlinandroidxexoplayerandroid-media3

Does the Android Transformer API optimize the input video to be streamable over the internet (faststart)?


Does anyone know if the Android Transformer API optimize the input video to be streamable over the internet (by moving the moov atom to the front)? Is there a setting you can set for that?

All I could find in the documentation was this:

The input can be of any container format supported by ExoPlayer, but the output is always an MP4 file.

Considering the output is always an MP4, it is probably optimized for web streaming, but I would like to know for sure if that is the default case or if it is something you need to set before running the transformer.


Solution

  • Short answer: currently it doesn't support Fast Start.

    Longer answer: The Media3 Transformer has 2 implementations of Muxer:

    1. DefaultMuxer uses FrameworkMuxer which uses the system MPEG4Writer (part of the Stagefright engine).
    2. InAppMuxer uses their own implementation called Mp4Muxer.

    Both Muxers write the moov atom last (after mdat).

    You can verify this using a tool such as AtomicParsley.

    AtomicParsley transformer-output.mp4 -T
    Atom ftyp @ 0 of size: 28, ends @ 28
    Atom mdat @ 28 of size: 11822589 (^), ends @ 11822617
                 (^)denotes a 64-bit atom length
    Atom moov @ 11822617 of size: 4424, ends @ 11827041
         Atom mvhd @ 11822625 of size: 108, ends @ 11822733
         Atom meta @ 11822733 of size: 177, ends @ 11822910
             Atom  @ 11822745 of size: 4296, ends @ 11827041
    

    The Media3 team is aware of the issue: https://github.com/androidx/media/issues/727