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

Packager Adaptation Set Switching doesn't work with forced command-line ordering #1402

Open
SteveR-PMP opened this issue May 17, 2024 · 2 comments
Labels
type: bug Something isn't working correctly
Milestone

Comments

@SteveR-PMP
Copy link
Contributor

System info

Operating System: all
Shaka Packager Version: latest

Issue and steps to reproduce the problem

Issue 1393 was created to address a problem with adaptation-set-switching using representationIDs instead of adaptationsetIDs. The fix has a problem with the --force_cl_index. If --force_cl_index=false is set, the manifest is correct.

Packager Command:
The problem becomes obvious with a large set of input files where the forced ordering makes a large difference. When used without --force_cl_index=false, the resulting manifest looks like this (grep "Adap|switching"):

<AdaptationSet id="0" contentType="video" maxWidth="960" maxHeight="544" frameRate="24000/1000" subsegmentAlignment="true">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="22,24"/>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" maxWidth="3840" maxHeight="2160" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="4,22"/>
</AdaptationSet>
<AdaptationSet id="2" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="4,24"/>
</AdaptationSet>
<AdaptationSet id="3" contentType="video" maxWidth="960" maxHeight="544" frameRate="24000/1000" subsegmentAlignment="true">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="20,23"/>
</AdaptationSet>
<AdaptationSet id="4" contentType="video" maxWidth="3840" maxHeight="2160" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="19,20"/>
</AdaptationSet>
<AdaptationSet id="5" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="19,23"/>
</AdaptationSet>
<AdaptationSet id="6" contentType="video" maxWidth="1024" maxHeight="576" frameRate="12288/512" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="21"/>
</AdaptationSet>
<AdaptationSet id="7" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="12288/512" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="0"/>
</AdaptationSet>
<AdaptationSet id="8" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="9" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="10" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="11" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="12" contentType="audio" lang="de" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="13" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="14" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="15" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="16" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="17" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="18" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="19" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="20" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="21" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="22" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="23" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="24" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>

What is the expected result?
When used with --force_cl_index=false, the correct manifest is created:

<AdaptationSet id="0" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="2" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="3" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="4" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="5" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="6" contentType="audio" lang="en-US" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="7" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="8" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="9" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="10" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="11" contentType="video" maxWidth="960" maxHeight="544" frameRate="24000/1000" subsegmentAlignment="true">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="20,24"/>
</AdaptationSet>
<AdaptationSet id="12" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="13" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="14" contentType="audio" lang="pt-BR" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="15" contentType="audio" lang="es-MX" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="16" contentType="audio" lang="fr" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="17" contentType="video" maxWidth="960" maxHeight="544" frameRate="24000/1000" subsegmentAlignment="true">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="21,23"/>
</AdaptationSet>
<AdaptationSet id="18" contentType="video" maxWidth="1024" maxHeight="576" frameRate="12288/512" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="22"/>
</AdaptationSet>
<AdaptationSet id="19" contentType="audio" lang="de" subsegmentStartsWithSAP="1" subsegmentAlignment="true">
</AdaptationSet>
<AdaptationSet id="20" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="11,24"/>
</AdaptationSet>
<AdaptationSet id="21" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="17,23"/>
</AdaptationSet>
<AdaptationSet id="22" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="12288/512" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="18"/>
</AdaptationSet>
<AdaptationSet id="23" contentType="video" maxWidth="3840" maxHeight="2160" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="17,21"/>
</AdaptationSet>
<AdaptationSet id="24" contentType="video" maxWidth="3840" maxHeight="2160" frameRate="24000/1000" subsegmentAlignment="true" par="16:9">
  <SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="11,20"/>
</AdaptationSet>
@vish91
Copy link
Contributor

vish91 commented May 17, 2024

@cosmin @joeyparrish this is from some testing after the PR for #1393 was merged. looks like its still failing from what @SteveR-PMP is testing.

@cosmin cosmin added the type: bug Something isn't working correctly label May 21, 2024
@github-actions github-actions bot added this to the v3.3 milestone May 21, 2024
@unext-wendong
Copy link

I think the problem comes from here.
https://github.com/shaka-project/shaka-packager/blob/v3.2.0/packager/mpd/base/period.cc#L147-L155

  // Iterate thru AdaptationSets and add them to one big Period element.
  // Also force AdaptationSets Id to incremental order, which might not
  // be the case if force_cl_index is used.
  int idx = 0;
  for (const auto& adaptation_set : adaptation_sets_) {
    auto child = adaptation_set->GetXml();
    if (!child || !child->SetId(idx++) || !period.AddChild(std::move(*child)))
      return std::nullopt;
  }

It's reseting the AdaptationSet id without updating the adaptation-set-switching SupplementalProperty during the MPD generation.

It feels unnecessary to me considering that the AdaptationSets have already been sorted in the beginning of the function (i.e. Period::GetXml).

unext-wendong added a commit to unext-wendong/shaka-packager that referenced this issue Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants