Menu

MP4Box: Generate DASH mpd with more than one period for Dash.js player

Help
2015-02-24
2015-03-02
  • Marc-Antoine

    Marc-Antoine - 2015-02-24

    Hi, i can't generate a mpd file with multiple period that works with dash.js player.

    The command I use:
    MP4Box -dash 10000 -profile live -rap -segment-name %s_ -dash-ctx out/stream.txt -out out/stream.mpd stream_a.m4a stream_v.mp4

    This creates a new MPD file with a period relative to the info in stream.txt, but if I run this command again, it replaces the MPD file instead of appending the new period to it.

    When I append the period manually, only the first video is played.

    Also, I would like to set the mode to dynamic, using the -dynamic command, so the client refreshes and check for updates. But when I set the mode to dynamic an error is thrown by dash.js: Uncaught Error: Must have @mediaPresentationDuration or @minimumUpdatePeriod on MPD or an explicit @duration on the last period.

    So I have to set minimumUpdatePeriod myself in the file, and again I cannot have more then one period. Is it because i'm not using MP4Box correctly??

    Thank you very much!

     

    Last edit: Marc-Antoine 2015-02-24
  • Marc-Antoine

    Marc-Antoine - 2015-02-24

    The files generated by MP4Box with
    MP4Box -dash 10000 -profile live -rap -segment-name %s_ -dash-ctx out/stream.txt -dynamic -out out/animaux.mpd animaux_a.m4a animaux_v.mp4

    MPD (minimumUpdatePeriod is not there)

    <?xml version="1.0"?>
    <!-- MPD file Generated with GPAC version 0.5.2-DEV-rev80-g29b60b6-master  on 2015-02-24T23:48:55Z-->
    <MPD xmlns="urn:mpeg:dash:schema:mpd:2011" minBufferTime="PT1.500000S" type="dynamic" availabilityStartTime="2015-02-24T23:48:55Z" timeShiftBufferDepth="PT0H0M0.00S" profiles="urn:mpeg:dash:profile:isoff-live:2011">
     <ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
      <Title>out/animaux.mpd generated by GPAC</Title>
     </ProgramInformation>
    
     <Period id="GENID_DEF" start="PT0H0M0.00S">
      <AdaptationSet segmentAlignment="true" lang="und">
       <Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="129674">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="44100" media="animaux_a_$Number$.m4s" startNumber="1" duration="441000" initialization="animaux_a_init.mp4"/>
       </Representation>
      </AdaptationSet>
      <AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720" maxFrameRate="30" par="16:9" lang="und">
       <Representation id="2" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" frameRate="30" sar="1:1" startWithSAP="1" bandwidth="501314">
        <SegmentTemplate timescale="15360" media="animaux_v_$Number$.m4s" startNumber="1" duration="153600" initialization="animaux_v_init.mp4"/>
       </Representation>
      </AdaptationSet>
     </Period>
    </MPD>
    

    ctx:

    [DASH]
    SessionType=dynamic
    TimeShiftBufferDepth=0
    StoreParams=yes
    PeriodSwitch=no
    GenerationTime=Tue Feb 24 23:48:54 2015
    
    GenerationNTP=3633810534
    GenerationNTPFraction=906238099
    MaxSegmentDuration=10.000000
    LastPeriodDuration=30.236
    LastActivePeriod=GENID_DEF
    SegmentTemplate=out/animaux_a_
    
    [Representation_1]
    ID=1
    Source=animaux_a.m4a
    Setup=yes
    InitializationSegment=out/animaux_a_init.mp4
    InitializationSegmentSize=839
    TKID_1_NextDecodingTime=1333376
    NextSegmentIndex=5
    NextFragmentIndex=5
    CumulatedDuration=30.233000
    Bandwidth=129674
    
    [SegmentsStartTimes]
    out/animaux_a_1.m4s=0
    out/animaux_a_2.m4s=9.984
    out/animaux_a_3.m4s=19.968
    out/animaux_a_4.m4s=29.952
    out/animaux_v_1.m4s=0
    out/animaux_v_2.m4s=7.133
    out/animaux_v_3.m4s=11.799
    out/animaux_v_4.m4s=20.865
    
    [Representation_2]
    ID=2
    Source=animaux_v.mp4
    Setup=yes
    InitializationSegment=out/animaux_v_init.mp4
    InitializationSegmentSize=924
    TKID_1_NextDecodingTime=462848
    NextSegmentIndex=5
    NextFragmentIndex=5
    CumulatedDuration=30.131000
    Bandwidth=501314
    
     

    Last edit: Marc-Antoine 2015-02-24
  • Jean Le Feuvre

    Jean Le Feuvre - 2015-02-25

    you will need to specify -mpd-refresh SOME_DUR if you directly want to use -dynamic. I will fix the code to throw an error if not set.

    The right way to deal with period in MP4Box is to use :period=N - for example

    1st pass:

    MP4Box -dash 1000 -dash-ctx ctx.txt -profile live -segment-name pref1_%s source.mp4:period=P1 -out manifest.mpd

    2nd pass:

    MP4Box -dash 1000 -dash-ctx ctx.txt -profile live -segment-name pref2_%s source.mp4:period=P2 -out manifest.mpd

     
  • Marc-Antoine

    Marc-Antoine - 2015-02-26

    Omg thank you. This information (-mpd-refresh and :period) is not available here: http://gpac.wp.mines-telecom.fr/mp4box/dash/

    Maybe it should be added :)

     
  • Jean Le Feuvre

    Jean Le Feuvre - 2015-02-26

    Yes the web doc should be updated (this is however documented in -h dash)

    FYI I have been doing some more fixes on multi period, you can now insert a period consisting of a single xlink by using:

    MP4Box -dash 1000 [...] source1.mp4:period=P1 :period=P2:xlink=http://foo.bar/linked.mpd:duration=10

    duration being the duration in second of the period to insert

    this can also be used with -dash-ctx

     
  • Marc-Antoine

    Marc-Antoine - 2015-03-01

    Is there any way to refresh the mpd file in static mode, or to stop timstamp check in dynamic mode?

    I need a video on demand mode where periods will be added when a user clicks on something. The closest I got is:

    MP4Box -dash 10000 -profile onDemand -rap -dash-ctx out/ctx.txt -mpd-refresh 5 -segment-name %s_ -out out/manifest.mpd p1_audio.m4a:period=P1 p1_video.mp4:period=P1

    MP4Box -dash 10000 -profile onDemand -rap -dash-ctx out/ctx.txt -mpd-refresh 5 -segment-name %s_ -out out/manifest.mpd p2_audio.m4a:period=P2 p2_video.mp4:period=P2

    But -mpd-refresh is not working, and in -dynamic mode, video won't start since it check the timestamp and video has been generated before.

     
  • Marc-Antoine

    Marc-Antoine - 2015-03-02

    Ok if I run the command above, and then add minimumUpdatePeriod="PT0H0M5.00S" manually to the file, I get the result I want. But I found no way of doing it otherwise.

     

    Last edit: Marc-Antoine 2015-03-02
  • Marc-Antoine

    Marc-Antoine - 2015-03-02

    Ok if I run the command above, and then add minimumUpdatePeriod="PT0H0M5.00S" manually to the file, I get the result I want. But I found no way of doing it otherwise.

    EDIT: I dont know why, but my msg was posted twice. You may delete this

     

    Last edit: Marc-Antoine 2015-03-02