shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.98k stars 507 forks source link

Period durations required in static manifest - mediaPresentationDuration optional #1022

Open s3bubble opened 2 years ago

s3bubble commented 2 years ago

Hi,

We use Shaka Packager to package our content then we upload our content to AWS S3.

We have recently been on support with AWS after trying to playback content and also insert ads using Mediatailor both were failing.

They stated.

We looked at the source manifest and found out that it doesn't contain the duration attribute which is the reason behind the failure. See below : Looking at the dash-IF[1] documents, we see that it is necessary for periods to include the duration attribute. A reference manifest can be seen here https://docs.aws.amazon.com/mediatailor/latest/ug/dash-manifest-vod.html

Here is our manifest encoded with Shaka

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT55.5S">
  <Period id="0">
    <AdaptationSet id="0" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="15360/512" segmentAlignment="true">
      <Representation id="0" bandwidth="568324" codecs="avc1.4d401f" mimeType="video/mp4" sar="1:1" width="1280" height="720">
        <SegmentTemplate timescale="15360" initialization="p720/init.mp4" media="p720/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="30720" r="26"/>
            <S t="829440" d="23040"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="2" bandwidth="159268" codecs="avc1.4d4015" mimeType="video/mp4" sar="1:1" width="426" height="240">
        <SegmentTemplate timescale="15360" initialization="p240/init.mp4" media="p240/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="30720" r="26"/>
            <S t="829440" d="23040"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="3" bandwidth="917080" codecs="avc1.4d4028" mimeType="video/mp4" sar="1:1" width="1920" height="1080">
        <SegmentTemplate timescale="15360" initialization="p1080/init.mp4" media="p1080/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="30720" r="26"/>
            <S t="829440" d="23040"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="4" bandwidth="254624" codecs="avc1.4d401e" mimeType="video/mp4" sar="1:1" width="640" height="360">
        <SegmentTemplate timescale="15360" initialization="p360/init.mp4" media="p360/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="30720" r="26"/>
            <S t="829440" d="23040"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="5" bandwidth="347396" codecs="avc1.4d401f" mimeType="video/mp4" sar="1:1" width="842" height="480">
        <SegmentTemplate timescale="15360" initialization="p480/init.mp4" media="p480/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="30720" r="26"/>
            <S t="829440" d="23040"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="1" contentType="audio" lang="en" segmentAlignment="true">
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
      <Representation id="1" bandwidth="135124" 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/default/init.mp4" media="audio/default/$Number$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="96256" r="2"/>
            <S t="288768" d="95232"/>
            <S t="384000" d="96256" r="2"/>
            <S t="672768" d="95232"/>
            <S t="768000" d="96256" r="2"/>
            <S t="1056768" d="95232"/>
            <S t="1152000" d="96256" r="2"/>
            <S t="1440768" d="95232"/>
            <S t="1536000" d="96256" r="2"/>
            <S t="1824768" d="95232"/>
            <S t="1920000" d="96256" r="2"/>
            <S t="2208768" d="95232"/>
            <S t="2304000" d="96256" r="2"/>
            <S t="2592768" d="71680"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

Any suggestion on how to implement this.

joeyparrish commented 2 years ago

Single-period VOD content does not need a duration attribute on <Period>. Instead, you have mediaPresentationDuration in the <MPD> element.

Does this help?

s3bubble commented 2 years ago

Thanks @joeyparrish going to pass this back to AWS.

We had this issue when encoding with Mediaconvert and this was the resolution.

After reviewing the MediaConvert job, we found that Write segment timeline in representation was disabled. DASH input manifests must contain segment templates with segment timelines in them. In our testing, once we enabled this setting in the DASH output group MediaTailor was able to accept the manifest and insert the ads properly.

For more information on integrating an MPEG-DASH source, please review

https://docs.aws.amazon.com/mediatailor/latest/ug/manifest-dash.html

We had to enable this.

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-mediaconvert/modules/dashisogroupsettings.html#writesegmenttimelineinrepresentation

Not sure if you have a similar option?

Let me see what AWS says.

s3bubble commented 2 years ago

Hi we have just got a response from the AWS Mediatailor team see below.

I have the following update from the service team:

Thanks for linking to that ticket at the Shaka Packager project.

We have updated our plan a little bit and plan to allow a manifest where the period@start and period@duration is either specified in the tag or is calculable from other tags' start and duration attributes. And the first period will not require a Period@start as it will be 0.

However we do plan to require a Period@duration on the final period of a static mpd, as the DASH-IF guidelines say:

    In a static presentation, the last period SHALL have a Period@duration.

https://dashif-documents.azurewebsites.net/Guidelines-TimingModel/master/Guidelines-TimingModel.html#timing-period-static

This means that will be allowed for the first period, but then either the subsequent ones must have a start, or the 1st+ ones must have a duration. And the final period must have a duration.

   <Period>
   <Period start=x>
   <Period start=y duration=z>

Is allowed.

   <Period duration=a>
   <Period duration=b>

Is also allowed.

About the MediaPresentationDuration, I see this in the DASH-IF doc:

MPD@mediaPresentationDuration MAY be present in an MPD. If present, it SHALL accurately match the duration between the zero point on the MPD timeline and the end of the last period, including the duration of any XLink periods. Clients SHALL calculate the total duration of a static presentation by adding up the durations of each period and SHALL NOT rely on the presence of MPD@mediaPresentationDuration.

https://dashif-documents.azurewebsites.net/Guidelines-TimingModel/master/Guidelines-TimingModel.html#timing-and-presentation-types

It doesn't look to me like MediaPresentationDuration is a substitute for Period@duration. Let me know if you/they have comments about that.

Thank you!

Is this something that could be implemented into the shaka packager? Or are there any comments to send back to the Mediatailor team. Thanks

joeyparrish commented 2 years ago

It certainly could be fixed in Shaka Packager. My understanding of the requirements was clearly out of date, and based on the original DASH client implementation in Shaka Player.

I'll label this as a bug and rename it accordingly. We would be happy to accept a PR to fix the implementation in Packager. It should be relatively straightforward to search for mediaPresentationDuration in the code and make some changes. You may need to update some expected outputs in tests to match.

s3bubble commented 2 years ago

Thanks @joeyparrish we will create a PR for this.

s3bubble commented 2 years ago

Could you point us in the right direction on how to create a PR for this.

We normally fork a repo create a branch make changes test and then push for the PR.

How do we test the code within our fork? we can build Shaka packager using docker.

docker pull google/shaka-packager

Then test with.

$ docker run -v /host_media_path/:/media -it --rm google/shaka-packager

That works fine but how do we test our fork with our updates.

docker pull s3bubble/shaka-packager

Gives us.

Using default tag: latest

Error response from daemon: pull access denied for s3bubble/shaka-packager, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Not sure the correct process to do this sorry not familiar with this workflow, could you give us some more information please.

Thanks