Menu

Generating DASH content for Android

2013-05-03
2013-06-05
  • Andrei Tiberiu Breană

    Hello.

    I'm trying to write an MPEG-DASH player for Android. Currently I'm trying to generate DASH content with MP4Box, but I haven't yet managed to create segments that can be played by Android's media player. I assume this is due to the fact that the segments lack index information or certain types of boxes (I don't know much about video formatting).

    Is there a way to generate segments that are individually playable (preferably, on Android)?

    I've also tried MP4Box's -split option to try and split an MP4 file into self-contained MP4 fragments, but I've noticed that the generated fragments do not have equal lengths (with a chosen length of 4s, I get clips ranging from 0 to 4 seconds). This would lead to unreliable representation switching in a DASH context..

    Has anyone managed to generate DASH content for Android? Are there any possible solutions?
    Any advice would be greatly appreciated.

    Thanks,

    Tiberiu

     
  • Cyril Concolato

    Cyril Concolato - 2013-05-06

    Hi Tiberiu,

    In DASH, segments are not (unless they are made self-initializing) individually playable. You can create self-initializing segments but simply concatenating (byte copy) the initalization segment (file_dashinit.mp4) with your segment.

    Splitting and fragmenting are 2 different operations. MP4Box splitting operation is meant for traditional file editing not for DASH. Fragmentation or segmentation are not editing operations per se, but more a publication operation used for DASH. The duration of fragments (segments) is approximate if you specify -frag-rap (-rap) because fragments (segments) will be aligned on RAP.

    As for the playback on Android, can you give us more details. Which player are you using? Which version of Android? Do you have a link to the specification of what should be supported?

     
  • Andrei Tiberiu Breană

    Thanks for your reply, Cyril!

    I'm targeting Android 4.0 and up (4.1.2 on my test device, at the moment). As I've said, I'm trying to code my own DASH player, so I'll probably be using Android's standard MediaPlayer class as a base for it. As far as I can see, GPAC can generate content supported by Android's media playback framework:
    http://developer.android.com/guide/appendix/media-formats.html

    I'll reply back once I try concatenating the segments with the init segment and see if they play.

    Tiberiu

     
  • Andrei Tiberiu Breană

    Ok, here's an update:

    I've been working with these datasets.
    I've concatenated some video segments with their init segment with a simple 'cat' command:

    cat initseg.mp4 seg<n>.m4s > playseg.mp4
    

    They play fine with the default Ubuntu media player (no seeking, though), but they won't play on my Android phone (Galaxy Nexus). I've managed to fix this by interleaving the output file, either by calling:

    MP4Box playseg.mp4 -inter 1
    

    or

    MP4Box playseg.mp4 -hint
    

    Now they play fine on the phone!
    So, basically, what I need now is a way to do the interleaving programmatically (inside the Android app). Has MP4Box been ported to Android?

     
  • Andrei Tiberiu Breană

    Hello again,

    I ran MP4Box -info on both the non-interleaved and the interleaved clips and diff'd the output:
    http://i.imgur.com/Z1eBYqM.jpg

    It seems that the non-interleaved clip is seen as having 00:00:00 duration - is this normal? I think this is why the non-interleaved files won't play on Android - the player detects them as having a 0s duration, so it opens and closes them immediately.
    I've also tried generating my own dash content with MP4Box -dash, but the results are the same.

    Any suggestions on how to remedy this problem?

     
  • Romain Bouqueau

    Romain Bouqueau - 2013-05-09

    Hi Tiberiu,

    When executing 'MP4Box -inter', you removed the fragments in your mp4 file. AFAIK fragmented mp4s are only supported starting at Android 4.2. Do you have a way to test on such a device, or did you hear about that before?

    GPAC has been ported to Android. You'll find an .apk on our website. Also there is a port of MP4Box that you can compile from Eclipse.

    Romain

     
  • Andrei Tiberiu Breană

    I didn't know about the fragmented MP4s and Android 4.2. I'll try and flash a 4.2 image on my phone asap and test again.

    I've tried compiling GPAC for Android myself, but got these errors while compiling gpac_extra_libs:

    $ ./gpac_build_all_extra_libs ~/android-ndk-r8d/
    [...]
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S: Assembler messages:
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:66: Error: missing ')'
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:66: Error: garbage following instruction -- `pld (r2,#0)'
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:259: Error: missing ')'
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:259: Error: garbage following instruction -- `pld (sp,#32)'
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:271: Error: missing ')'
    /home/tibi/gpac/gpac_extra_libs/build/android/jni/jpegdroid/jidctfst.S:271: Error: garbage following instruction -- `pld (ip,#32)'
    make: *** [/home/tibi/gpac/gpac_extra_libs/build/android/obj/local/armeabi/objs/jpegdroid/jpegdroid/jidctfst.o] Error 1
    ./gpac_build_all_extra_libs: line 30: $'\302\240exit': command not found
    

    How does the MP4Box Android port work? I only need the standalone executable binary, so that I might call it from Java code.
    I don't suppose anyone has a statically-linked MP4Box ARM binary lying around? :)

     
  • Andrei Tiberiu Breană

    Ok, I've installed the CyanogenMod 10.1 RC (released yesterday), based on Android 4.2.2, tried to play the segments, but they still don't work. :(

     
  • Romain Bouqueau

    Romain Bouqueau - 2013-05-10

    Ok. To sum up:
    1. There an issue when compiling the dependencies with the lastest ndk, we'll have a look;
    2. It seems the latest Android doesn't support fragmented mp4 and you indeed need some calls to gpac to extract the data from the fragments.

    Is there anything more to help you?

    Romain

     
  • Andrei Tiberiu Breană

    1. That's actually not the latest version of the NDK; r8e is the latest.
    2. Correct. I need either a way to programmatically un-fragment or interleave the concatenated DASH segments, or an MP4Box ARM binary to call from the code.
    Or a way to generate un-fragmented DASH video, but I don't think this is possible.

    Thanks,
    Tiberiu