shaka-packager icon indicating copy to clipboard operation
shaka-packager copied to clipboard

Is startNumber needed on $time$ based segmentTemplate DASH manifest (and startNumber "drift" between Representations)

Open bugre opened this issue 4 years ago • 2 comments

System info

Operating System:

  • Flatcar Linux - kernel 5.4.66-flatcar and
  • Flatcar Linux - kernel 4.19.107-flatcar (also testes on CoreOS)

Shaka Packager Version:

  • v2.3.0-5bf8ad5 and
  • v2.4.3-dd9870075f

Issue and steps to reproduce the problem

Hi, We're packaging live feeds using Shaka Packager to generate dash streams.

Packager is run using this command:

packager \  in=udp://239.1.1.111:5000?interface=172.31.15.15&reuse=1&buffer_size=52428800,stream=video,init_segment=/volume/packager/video0_init_r0s5fa04b4c.mp4,segment_template=/volume/packager/video0_$Time$_r0s5fa04b4c.m4s,bw=4000000 \
  in=udp://239.1.1.111:5000?interface=172.31.15.15&reuse=1&buffer_size=52428800,stream=1,language=fra,init_segment=/volume/packager/audio0_init_r0s5fa04b4c.mp4,segment_template=/volume/packager/audio0_$Time$_r0s5fa04b4c.m4s \
  in=udp://239.1.1.111:5000?interface=172.31.15.15&reuse=1&buffer_size=52428800,stream=2,language=qaa,init_segment=/volume/packager/audio1_init_r0s5fa04b4c.mp4,segment_template=/volume/packager/audio1_$Time$_r0s5fa04b4c.m4s \
  in=udp://239.1.1.111:5001?interface=172.31.15.15&reuse=1&buffer_size=52428800,stream=video,init_segment=/volume/packager/video1_init_r0s5fa04b4c.mp4,segment_template=/volume/packager/video1_$Time$_r0s5fa04b4c.m4s,bw=2000000 \
  --segment_duration 8.0 --time_shift_buffer_depth 21600 --minimum_update_period 8.0 --default_language fra --min_buffer_time 8.0 --strip_parameter_set_nalus=true --protection_scheme cenc --clear_lead 0 \
  --enable_widevine_encryption --content_id xxxx --aes_signing_iv xxx --signer tvup --aes_signing_key xxx --key_server_url https://license.widevine.com/xxx --mpd_output /volume/packager/stream.mpd

This generates a $time$ segmentTemplate, but it also includes a 'startNumber' that we'd understood was only used/needed if we where using '$number$ based segmentTemplate.

Could you help us understand what the startNumber is/should be used for? Is it needed?

The issue we're researching/facing is that some of the streams, after a few hours packaging, will get a difference in the startNumber value for different video representations. Usually the difference is of one unit. And, this, apparently, generates problems for Exoplayer (that we use on some devices for playback) when switching between the representations. The playback freezes for the duration of one segment (around).

Bellow is a sample manifest after a few hours streaming with such a situation (i've removed the audio and drm part, but could share the entire manifest if needed.

     <?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version v2.3.0-5bf8ad5-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="PT8S" type="dynamic" publishTime="2020-10-31T09:49:00Z" availabilityStartTime="2020-06-11T10:16:27Z" minimumUpdatePeriod="PT8S" timeShiftBufferDepth="PT21600S">
  <Period id="0" start="PT0S">
...
    <AdaptationSet id="1" contentType="video" maxWidth="1280" maxHeight="720" frameRate="90000/3600" par="16:9">
      <Representation id="1" bandwidth="2000000" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1" width="960" height="540">
        <SegmentTemplate timescale="90000" initialization="video1_init_r0s5ee23b12.mp4" media="video1_$Time$_r0s5ee23b12.m4s" startNumber="1528940">
          <SegmentTimeline>
            <S t="1102099650304" d="720000" r="2700"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="3" bandwidth="4000000" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1" width="1280" height="720">
        <SegmentTemplate timescale="90000" initialization="video0_init_r0s5ee23b12.mp4" media="video0_$Time$_r0s5ee23b12.m4s" startNumber="1528939">
          <SegmentTimeline>
            <S t="1102099650304" d="720000" r="2700"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
...
  </Period>
</MPD>

We also find id odd that 'startNumber' of the Representation id "3" is one less than the one of id "1", but, both representations have the same 't', 'd' and 'r' values?

This manifest was generated with packager version v2.3.0, but we also see the same behaviour with version v2.4.3

We see this situation on streams generated with ffmpeg encoder but also with streams generated by a comercial encoding solution.

Is there any option that would allow us to generate a $time$ based manifest without the 'startNumber' atribute on the SegmentTemplate element ?

Thanks,

bugre avatar Nov 04 '20 00:11 bugre

What can/could cause that startNumber differs between two Representations that have aligned GOP's and are generated by the same encoder?

bugre avatar Nov 08 '20 15:11 bugre

Can you share an ffmpeg command line for the streams? Also does this still reproduce with the latest version (3.1)?

cosmin avatar May 09 '24 23:05 cosmin

Closing due to inactivity. If this is still an issue for you or if you have further questions, the OP can ask shaka-bot to reopen it by including @shaka-bot reopen in a comment.

github-actions[bot] avatar May 17 '24 00:05 github-actions[bot]