Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment Template with Duration #400

Closed
ltrayanov opened this issue May 23, 2018 · 11 comments
Closed

Segment Template with Duration #400

ltrayanov opened this issue May 23, 2018 · 11 comments
Labels
status: archived Archived and locked; will not be updated type: question A question from the community

Comments

@ltrayanov
Copy link

Hi,
I am working on a project of packaging a low latency live stream. One of the suggestions that I receive was to use a SegmentTemplate with duration. We tried that with ffmpeg and our glass to glass latency was around 2sec. Added benefit was the lower network activity since minimumUpdatePeriod was set very high.

How can we set the ShakaPackager to use a Segment Template with Duration? Any help would be greatly appreciated.

@vaage vaage added the type: question A question from the community label May 23, 2018
@vaage
Copy link
Contributor

vaage commented May 23, 2018

@ltrayanov Our segment template system currently supports Segment Number and Segment Time. I have not heard of segment template with duration. Could you explain to me how that should work?

@ltrayanov
Copy link
Author

ltrayanov commented May 23, 2018

@vaage The manifest of the a template with duration includes info about all future segments and clients don't need to do manifest updates to learn about future segments. The ffmpeg argument is:

-use_template 1 \ # Use templated names for output
-use_timeline 0 \ # Dont use the segment time in the template

The segment template in the generated mpd file should look like:

SegmentTemplate timescale="1000000" duration="1000000" initialization="init-$RepresentationID$.mp4" media="test-$RepresentationID$-$Number%05d$.mp4" startNumber="1">
</SegmentTemplate

Thats the only way I achieved a low latency live stream.

@vaage
Copy link
Contributor

vaage commented May 23, 2018

@ltrayanov Did part of your message get erased by mistake? You say "the segment template in the generated mpd file should like like:" and then there is nothing.

@kqyang
Copy link
Contributor

kqyang commented May 23, 2018

@ltrayanov Looks like you are looking for SegmentTemplate with constant duration. We have experimental support for this in Shaka Packager under flags: --allow_approximate_segment_timeline --segment_template_constant_duration. Both flags needs to be set in addition to normal packaging command: https://google.github.io/shaka-packager/html/tutorials/live.html.

@ltrayanov
Copy link
Author

ltrayanov commented May 24, 2018

@vaage Sorry about that. The segment template in the generated mpd file should look like:
SegmentTemplate timescale="1000000" duration="1000000" initialization="init-$RepresentationID$.mp4" media="test-$RepresentationID$-$Number%05d$.mp4" startNumber="1">
</SegmentTemplate

@vaage
Copy link
Contributor

vaage commented May 24, 2018

@ltrayanov Thank you for sharing that. Did what @kqyang suggest work for you?

@ltrayanov
Copy link
Author

@vaage I will try the flags on Tuesday next week and post an update. Thanks!

@andrea-f
Copy link

@vaage thanks for sharing the flags, I am currently running:

  'input=forzalazio.mp4,stream=video,init_segment=video/init.mp4,segment_template=video/$Number$.m4s' \
  --segment_duration 1 \
  'input=forzalazio.mp4,stream=audio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s' \
  --segment_duration 1 \
  --enable_widevine_decryption \
  --enable_widevine_encryption \
  --key_server_url https://license.uat.widevine.com/cenc/getcontentkey/widevine_test \
  --content_id HEXSTRING \
  --signer widevine_test \
  --aes_signing_key 1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9 \
  --aes_signing_iv d58ce954203b7c9a9a9d467f59839249 \
  --mpd_output manifest.mpd \
  --allow_approximate_segment_timeline \
  --segment_template_constant_duration \

Which gives me:

<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version 53aa775ea4-release-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="2018-10-31T20:22:35Z" availabilityStartTime="2018-10-31T20:22:27Z" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
  <Period id="0" start="PT0S">
    <AdaptationSet id="0" contentType="audio" lang="en" segmentAlignment="true">
      <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00be9459-7212-5f91-903c-4199caacf619"/>
      <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
        <cenc:pssh>AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnBlYXJsdHZfdGVzdF9leG9wbGF5ZXJI49yVmwY=</cenc:pssh>
      </ContentProtection>
      <Representation id="0" bandwidth="326673" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="48000" initialization="audio/init.mp4" media="audio/$Number$.m4s" startNumber="1" duration="48000"/>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="1" contentType="video" width="1280" height="720" frameRate="30000/1001" segmentAlignment="true" par="16:9">
      <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="110f6be6-8e27-5787-95a4-14f9bb45ff44"/>
      <ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
        <cenc:pssh>AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnBlYXJsdHZfdGVzdF9leG9wbGF5ZXJI49yVmwY=</cenc:pssh>
      </ContentProtection>
      <Representation id="1" bandwidth="13488008" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1">
        <SegmentTemplate timescale="30000" initialization="video/init.mp4" media="video/$Number$.m4s" startNumber="1" duration="30000"/>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

So correctly, there are no SegmentTimeline tags. To serve the file I am using an hosted version of DASHIF v1.5 and playback on https://bitmovin.com/demos/drm.

@kqyang kqyang changed the title Low Latency Live Stream Segment Template with Duration Nov 8, 2018
@kqyang
Copy link
Contributor

kqyang commented Nov 8, 2018

Renamed Segment Template with Duration to better reflect what this issue is. We'll be working on Low Latency with Chunked CMAF in Q1 2019, which can further reduce the latency. Stay tuned.

Closing this issue as it is addressed. Feel free to reply or re-open it if there are other questions.

@kqyang kqyang closed this as completed Nov 8, 2018
@michael-riha
Copy link

michael-riha commented Dec 17, 2018

@ltrayanov

We tried that with ffmpeg and our glass to glass latency was around 2sec
Can you tell me how you did it?

I tried so many variations of arguments in ffmpeg without any success.
I never got a working chunked fragment with multiple moof+mdata-chunkes.
How to?

@kqyang
Copy link
Contributor

kqyang commented Dec 17, 2018

@michael-riha You can feed the output from ffmpeg to Shaka Packager. Packager generates a chunk with multiple (moof+mdat)s if you set segment_duration to a multiple of fragment_duration.

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Jan 7, 2019
@shaka-project shaka-project locked and limited conversation to collaborators Jan 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: question A question from the community
Projects
None yet
Development

No branches or pull requests

6 participants