8000 Improve conversion by incorporating color and alignment by Lucki · Pull Request #17 · Paco8/ttml2ssa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve conversion by incorporating color and alignment #17

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Lucki
Copy link
@Lucki Lucki commented Apr 4, 2025

These changes are tailored towards subtitle files coming from the German televisions (ARD, NDR, ZDF, ZDF Neo, ORF, …) being converted into the ASS format. I do hope they're not breaking any other test cases, but I have no way to verify that.


The first commit is a fix finding the position styles. They are behind a namespace in my test files which are now correctly found. Notice the style, styling, region and layout tags being prefixed with the namespace tt in the following very common header.

Example header
  <tt:head>
    <tt:metadata>
      <ebuttm:documentMetadata>
        <ebuttm:documentEbuttVersion>v1.0</ebuttm:documentEbuttVersion>
      </ebuttm:documentMetadata>
    </tt:metadata>
    <tt:styling>
      <tt:style xml:id="defaultStyle" tts:fontFamily="Verdana,Arial,Tiresias" tts:fontSize="160%" tts:lineHeight="125%" />
      <tt:style xml:id="textBlack" tts:color="#000000" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textRed" tts:color="#FF0000" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textGreen" tts:color="#00FF00" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textYellow" tts:color="#FFFF00" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textBlue" tts:color="#0000FF" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textMagenta" tts:color="#FF00FF" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textCyan" tts:color="#00FFFF" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textWhite" tts:color="#FFFFFF" tts:backgroundColor="#000000c2" />
      <tt:style xml:id="textCenter" tts:textAlign="center" />
      <tt:style xml:id="textLeft" tts:textAlign="left" />
      <tt:style xml:id="textRight" tts:textAlign="right" />
    </tt:styling>
    <tt:layout>
      <tt:region xml:id="top" tts:origin="10% 10%" tts:extent="80% 80%" tts:displayAlign="before" />
      <tt:region xml:id="bottom" tts:origin="10% 10%" tts:extent="80% 80%" tts:displayAlign="after" />
    </tt:layout>
  </tt:head>

The next two commits are reading the color values for both foreground and background and assigning the values to inline modifiers.

Details
      <tt:p xml:id="sub1" style="textCenter" region="top" begin="00:00:01.680" end="00:00:04.480">
        <tt:span style="textYellow">Wie ist Hélène so?</tt:span>
        <tt:br />
        <tt:span style="textGreen">Fragen Sie Villanelle.</tt:span>
      </tt:p>
Dialogue: 0,0:00:01.76,0:00:04.40,Default,,0,0,0,,{\an8}{\1c&H00FFFF&\1a&H00&\3c&H000000&\3a&H3D&}Wie ist Hélène so?\N{\1c&H00FF00&\1a&H00&\3c&H000000&\3a&H3D&}Fragen Sie Villanelle.

grafik


The last commit makes use of the rarely used textAlign tag. Those allow shifting text to either side away from the center while still being at the same height. To make calculations easier, I changed the current format of the position (top|bottom) into the ASS format (8|2). This allows to subtract or add 1 and have the correct positioning on screen regarding the ASS numpad layout (1..9).

Details

In this example, the tt:p is manually edited to feature the style="textLeft" tag. The header is the same as in the first example above.

      <tt:p xml:id="sub3" style="textLeft" region="bottom" begin="00:00:06.360" end="00:00:09.240">
        <tt:span style="textCyan">Ich bin nicht so beschissen,</tt:span>
        <tt:br />
        <tt:span style="textCyan">wie manche denken.</tt:span>
      </tt:p>
Dialogue: 0,0:00:06.44,0:00:09.16,Default,,0,0,0,,{\an1}{\1c&HFFFF00&\1a&H00&\3c&H000000&\3a&H3D&}Ich bin nicht so beschissen,\N{\1c&HFFFF00&\1a&H00&\3c&H000000&\3a&H3D&}wie manche denken.

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0