androidx / androidx/media

TTML style attributes are not read from the region tag

Open
#1,469 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

enhancement low priority
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

Application : https://play.google.com/store/apps/details?id=com.canal.android.canal&hl=fr
Device : Redmi Note 11 Pro 5G (issue not specific to device)
Android : 13 TKQ1.221114.001

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Play a DASH stream containing TTML subtitles, like the following:

<?xml version="1.0" encoding="utf-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling%22  xmlns:ttp="http://www.w3.org/ns/ttml#parameter%22  xml:lang="" ttp:cellResolution="40 24">
  <head>
    <styling>
      <style xml:id="speakerStyleDoubleHeight" tts:fontFamily="proportionalSansSerif" tts:fontSize="166.66%" tts:lineHeight="120.00%" tts:overflow="visible" tts:backgroundColor="transparent" tts:color="white" tts:textOutline="black 2px"/>
    </styling>
  <layout>
    <region xml:id="speaker_1" tts:origin="7.50% 62.50%" tts:extent="50.00% 16.67%" tts:displayAlign="after" tts:textAlign="left" style="speakerStyleDoubleHeight"/>
  </layout>
  </head>
  <body>
    <div>
      <p begin="82287:47:57.880" end="82287:47:59.360" region="speaker_1">
      subtitle text
      </p>
    </div>
  </body>
</tt>
Expected result

The above subtitle is left aligned in the given region; i.e. the tts:textAlign style element has been taken into account.

Actual result

The above subtitle is centered on screen; the tts:textAlign style element has been ignored.

See TTML specification https://www.w3.org/TR/2018/REC-ttml1-20181108/#layout-vocabulary-region:

<region
  [begin](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-attribute-begin) = [<timeExpression>](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-value-timeExpression)
  [dur](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-attribute-dur) = [<timeExpression>](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-value-timeExpression)
  [end](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-attribute-end) = [<timeExpression>](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-value-timeExpression)
  [style](https://www.w3.org/TR/2018/REC-ttml1-20181108/#style-attribute-style) = IDREFS
  [timeContainer](https://www.w3.org/TR/2018/REC-ttml1-20181108/#timing-attribute-timeContainer) = (par|seq)
  [ttm:role](https://www.w3.org/TR/2018/REC-ttml1-20181108/#metadata-attribute-role) = string
  [xml:id](https://www.w3.org/TR/2018/REC-ttml1-20181108/#content-attribute-id) = ID
  [xml:lang](https://www.w3.org/TR/2018/REC-ttml1-20181108/#content-attribute-lang) = string
  [xml:space](https://www.w3.org/TR/2018/REC-ttml1-20181108/#content-attribute-space) = (default|preserve)
  {any attribute in TT Style namespace}
  {any attribute not in default or any TT namespace}>
  Content: [Metadata.class](https://www.w3.org/TR/2018/REC-ttml1-20181108/#element-vocab-group-table)*, [Animation.class](https://www.w3.org/TR/2018/REC-ttml1-20181108/#element-vocab-group-table)*, [style](https://www.w3.org/TR/2018/REC-ttml1-20181108/#styling-vocabulary-style)*
</region>

See function parseRegionAttributes() : https://github.com/androidx/media/blob/release/libraries/extractor/src/main/java/androidx/media3/extractor/text/ttml/TtmlParser.java#L352

Media
<?xml version="1.0" encoding="utf-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling%22  xmlns:ttp="http://www.w3.org/ns/ttml#parameter%22  xml:lang="" ttp:cellResolution="40 24">
  <head>
    <styling>
      <style xml:id="speakerStyleDoubleHeight" tts:fontFamily="proportionalSansSerif" tts:fontSize="166.66%" tts:lineHeight="120.00%" tts:overflow="visible" tts:backgroundColor="transparent" tts:color="white" tts:textOutline="black 2px"/>
    </styling>
  <layout>
    <region xml:id="speaker_1" tts:origin="7.50% 62.50%" tts:extent="50.00% 16.67%" tts:displayAlign="after" tts:textAlign="left" style="speakerStyleDoubleHeight"/>
  </layout>
  </head>
  <body>
    <div>
      <p begin="82287:47:57.880" end="82287:47:59.360" region="speaker_1">
      subtitle text
      </p>
    </div>
  </body>
</tt>
Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.