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

Wrong pixelAspectRatio population in DASH #2614

Merged
merged 3 commits into from
Jun 3, 2020

Conversation

avelad
Copy link
Member

@avelad avelad commented Jun 3, 2020

The current implementation of pixelAspectRatio in DASH is wrong. @par in DASH is "display aspect ratio" so the correct is populate this field with @sar

@TheModMaker
Copy link
Contributor

In DASH, the @sar attribute specifies the sample aspect ratio, which is actually a synonym for "pixel aspect ratio". Confusingly, we incorrectly parse the @par attribute to mean that, when in fact it is the "picture aspect ratio", which is a synonym for "display aspect ratio".

So to summarize:

  • @sar is the "sample aspect ratio" or "pixel aspect ratio", which is the aspect ratio of the pixels themselves.
  • @par is the "picture aspect ratio" or "display aspect ratio" (DAR), which is the aspect ratio of the displayed image.
  • The "storage aspect ratio" is the aspect ratio of the image in pixels. It is width:height of the pixels of the image.

@avelad
Copy link
Member Author

avelad commented Jun 3, 2020

Hum, I can change the name if you want.

Do you want me to change PAR name too?

@TheModMaker
Copy link
Contributor

Since the @par is just the width:height of the image, apps could easily get this from those attributes. How about just changing the DASH parser to use @sar to fill the pixelAspectRatio property? I don't see a way to get the storage aspect ratio from DASH without just calculating it from the pixel aspect ratio and the displayed image.

@avelad
Copy link
Member Author

avelad commented Jun 3, 2020

I have several live streams with the following:

<AdaptationSet id="4" group="2" frameRate="25" mimeType="video/mp4" startWithSAP="1" contentType="video" par="16:9" minBandwidth="700000" maxBandwidth="1500000" minWidth="480" maxWidth="1024" minHeight="270" maxHeight="576" segmentAlignment="true">
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate timescale="25" initialization="boing-$RepresentationID$-scale=25-init.mp4" media="boing-$RepresentationID$-scale=25-$Time$.mp4">
        <SegmentTimeline>
          <S t="4278345222" d="50" r="149" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation id="avc1_700000=1" bandwidth="700000" width="480" height="270" sar="1:1" codecs="avc1.640015" />
      <Representation id="avc1_1000000=4" bandwidth="1000000" width="640" height="360" sar="1:1" codecs="avc1.64001e" />
      <Representation id="avc1_1500000=5" bandwidth="1500000" width="720" height="576" sar="64:45" codecs="avc1.64001e" />
    </AdaptationSet>

720x576 is taken from a dvb-t source, the rest are converted qualities.
Actually applying the correct values ​​the video has 1024x576

If I understand you well ... really the problem is that the parsing in DASH is wrong?

@TheModMaker
Copy link
Contributor

Actually, it looks like the @width and @height attributes specify the size in pixels, not the display size. So you could get the "storage aspect ratio" by taking the width:height. The @par is just (width:height)*@sar.

So, with a @width=720, @height=576, @sar=64:45, then @par=(720*64):(576*45) == 46080:25920 == 1024:576 == 16:9. This being the "display aspect ratio".

So in this case, the "storage aspect ratio" would be 720:576 or 5:4.

I propose we expose the 64:45 value as pixelAspectRatio in the API since width and height are already exposed. Currently, we would expose the value as 16:9, which would be incorrect.

@avelad
Copy link
Member Author

avelad commented Jun 3, 2020

Ok, I’ll update the PR to change the dash parser. pixelAspectRatio should be populate with @sar

Alvaro Velad added 2 commits June 3, 2020 20:16
…in DASH is "display aspect ratio" so the correct is populate this field with @sar
@avelad avelad changed the title Expose Storage Aspect Ratio (SAR) Wrong pixelAspectRatio population in DASH Jun 3, 2020
@avelad
Copy link
Member Author

avelad commented Jun 3, 2020

I updated the PR, @TheModMaker can you review?

@shaka-bot
Copy link
Collaborator

All tests passed!

@TheModMaker TheModMaker merged commit 1568d28 into shaka-project:master Jun 3, 2020
@avelad avelad deleted the storage-aspect-ratio branch June 4, 2020 06:05
joeyparrish pushed a commit that referenced this pull request Jun 11, 2020
The current implementation of pixelAspectRatio in DASH is wrong. `@par` in DASH is "picture  aspect ratio" so the correct is populate this field with `@sar`.

Backported to v2.5.x

Change-Id: I5e492e17cee3895af43782b6799e09baa31cffcb
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants