Youtube Timed Text Caption box alignment issue - youtube

I want to be able to show 2 lines of captions/subtitles on a youtube video using the youtube timed text (.ytt) format
<?xml version="1.0" encoding="utf-8"?>
<timedtext format="3">
<head>
<wp id="0" ap="0" ah="0" av="0" />
<ws id="0" ju="0" pd="0" sd="0" />
<pen id="0" sz="100" fs="0" />
</head>
<body>
<p t="1" d="4988" wp="0" ws="0"><s></s><s p="0">​ ROW 1: XXXXXXXXXX </s>
<s p="0"> ​​ROW 2: XXXXXXXXXX </s></p>
</body></timedtext>
The caption shows correctly with the background box aligned:
However, as soon as I change the font to fs="1" (mono space) or add a color fc="#FF0000" the background boxes shift.
Is there another way to add the 2 lines of paragraphs to keep the background box aligned?
Btw, I'm using the ytt format instead of the ttml format because I need to be able to set the font to monospace and add a font color.

I'm not sure if there is another way. In your case I would make sure that the spacing around the line break matches.
AFAIK, a default padding of one white-space character is present at the beginning and end of the paragraph. But adding a line break doesn't add by default this white-space character to the end of the first line and beginning of the second line. We need to add them back in :
<p t="1" d="4988" wp="0" ws="0"><s></s><s p="0">ROW 1: XXXXXXXXXX </s>​<s p="0">​
ROW 2: XXXXXXXXXX</s></p>
In addition, I would suggest to use Unicode characters for white-space characters and zero width space ​.

Using multiple spans has a bug. Try this out. Hope it helps.
In the code below, place a zero-width space after the first span.
<p t="1" d="4988" wp="0" ws="0"><s></s><s p="0">​ ROW 1: XXXXXXXXXX </s>
<s p="0"> ​​ROW 2: XXXXXXXXXX </s></p>
add ​ between span. try use the code below:
<p t="1" d="4988" wp="0" ws="0"><s></s>​<s p="0">​ROW 1: XXXXXXXXXX </s>
<s p="0">ROW 2: XXXXXXXXXX </s></p>

After playing with the format a bunch more I finally got it to work. The key is the extra <s></s> and each <s> paragraph on its own line. Also, extra spacing is now needed at the beginning and end of the text
<?xml version="1.0" encoding="utf-8"?>
<timedtext format="3">
<head>
<wp id="0" ap="0" ah="0" av="0" />
<ws id="0" ju="0" pd="0" sd="0" />
<pen id="0" sz="100" fs="1" />
</head>
<body>
<p t="1" d="4988" wp="0" ws="0">
<s></s>
<s p="0"> ROW 1: XXXXXXXXXX </s>
<s p="0"> ROW 2: XXXXXXXXXX </s>
</p>
</body></timedtext>

Related

How calculate $Time$ variable for name of dash media segments?

I have an MPD playlist. I'd like to find out what are URLs of media segments for next period.
The example is like this
<SegmentTemplate timescale="10000000" initialization="Video-$RepresentationID$-init.mp4" media="Video-$RepresentationID$-$Time$.mp4">
<SegmentTimeline>
<S t="2083838574453329" d="100053337" />
<S d="100053332" r="1" />
<S d="99839999" />
<S d="100053337" />
</SegmentTimeline>
</SegmentTemplate>
How calculate $Time$ variabel for each period of dash segment?
The DASH specification is freely available at https://www.iso.org/standard/79329.html and clearly documents how to determine the URL of any segment listed in the manifest.

Pretty html formatted string on a vaadin Label

how can I to add an html formatted string on a vaadin label so that it looks pretty?
It must be formatted with bold text, italic text, new lines, html things basically.
I'm using Vaadin 14. Thank you so much in advance!
You'll want to use new Html("");
Label corresponds to <label> and should only be used to label input fields.
Have you tried something like this:
Label label = new Label();
label.getElement().setProperty("innerHTML","Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>");
Or this:
String yourContent = "Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>";
Html html = new Html("<text>" + yourContent + "</text>");

TCPDF not render tabs space with <pre> tag

I'm using TCPDF to render a simple HTML that mainly have the data between "pre" tag. All is fine except when I have text separated by tabs spaces. Then the text is misaligned and don't show the text aligned.
I'm testing the first sample code.
https://tcpdf.org/examples/example_001/
Then I replace:
$html = <<<EOD
<pre>
RESEARCH LIST
XX-Name: Notes:
10-Progress Get +20
20-Research Get +2
27-Advanced Research Get +5
28-Atmospheric Converters Terraforming +1
29-Comet Ds Terraforming +4
</pre>
EOD;
I get the PDF but the text isn't aligned with columns.
If I open as .html is aligned correctly.
<HTML>
<HEAD>
<TITLE>XYZ</TITLE>
</HEAD>
<body>
<PRE>
DC-Name: Notes:
10-Progress Get +20
20-Research Get +2
27-Advanced Research Get +5
28-Atmospheric Converters Terraforming +1
29-Comet Ds Terraforming +4
</PRE>
</body>
</HTML>
What is wrong?
Salut,
Josep M

Enable Break Line or New Line in Textarea when press enter

How can i enable a Break Line or New Line in Textarea when i press the Enter Key ?
So that if I press the ENTER it saves in the form of New Line in database.
I have already searched some topics but it hasn't helped me.
Here is my Textarea Code:
<textarea name="post" id="post" class="valid Post_Text_Area" placeholder="Write something here..." ></textarea>
I tried this JS Code so far. but it hasn't worked for me
JavaScript: How to add line breaks to an HTML textarea?
Newlines in textarea's are saved into the database by default.
To generate them as Html BR codes, use nl2br($yourTextVariable) $yourTextVariable will be the variable you fetch from database. so use it like this :
<?php echo nl2br($yourTextVariable); ?>
This transforms newline to <br />
Another solution is put the output into <pre> tag or just style it with css white-space: pre. It will not swallow multiple spaces.

Razor - How to prevent unwanted line break in view source when #{} or #() was used?

Whenver I use #{ } or #( ) in the webpage and run it from Visual Studio, then in the web-browser, i noticed in the view source are are line break before the #{ syntax and another line break after the } syntax.
Is there a way to prevent line break so the view source become easier to read?
Thanks...
I don't think there is anything you can do regarding the line breaks. The formatting is as per source file after its been compiled and rendered from the server side.
The effect to the end user in terms of layout is nothing as its not a html line break: <br>
You can put server side code in-line as per the example below which will stop the line spacing:
a<br/>#{ /*some code 1 that does not produce a line break*/}
b<br />
c<br />
#{
/*some code 2 that does produce line breaks*/
}
d<br />
e<br />
this will produce the following:
a<br />
b<br />
c<br />
d<br />
e<br />

Resources