Subject: [Cellar] Storing USF subtitles in Matroska

From: "Sebastian G. <bastik>" <[email-masked]>
Date: Mon, 14 Mar 2016 19:35:47 +0100

Hello,

because the storage for WebVTT subtitles is being specified now I
noticed that USF is listed in the Codec Specs [1], but the specification
that goes into details [2] says "Under Construction".

The Codec Specs says it is mostly defined but not typed out yet.

Is this still something that has to be done?

The specification of the USF subtitle format seems to be located at some
private website [3].

Greetings,
Sebastian

[1] https://www.matroska.org/technical/specs/codecid/index.html
[2] https://www.matroska.org/technical/specs/subtitles/usf.html
[3] http://www.titlevision.dk/usf.htm

---

From: Moritz Bunkus <[email-masked]>
Date: Sun, 20 Mar 2016 19:38:50 +0100

Hey,

> Is this still something that has to be done?

mkvmerge has supported USF for ages, and there have been no changes in
just as long (last substantial change to USF support was in 2005). I'd
consider it… stable. Maybe »dead« would be more appropriate :)

Basically the specs could be described like this:

(A) CodecID: S_TEXT/USF

(B) CodecPrivate: The content of CodecPrivate is the XML content of the
    whole USF file with the <subtitles> node and all of its children
    removed.

(C) Entries: <subtitle> child node of the <subtitles> node is converted
    into a single Matroska block. The <subtitle>'s »start« attribute is
    used as the block's start timestamp. The difference between the
    node's »stop« and »start« attributes is used as the block's duration.

    The block's content is the whole <text> child of the <subtitle> node
    including all of its content. The opening and closing <text> </text>
    tags are part of the content, too.

Example. Let's assume this simple USF file:

--start-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- DOCTYPE USFSubtitles SYSTEM "USFV100.dtd" -->
<?xml-stylesheet type="text/xsl" href="USFV100.xsl"?>
<USFSubtitles version="1.00">
	<metadata>
	 <resolution x="640" y="480"></resolution>
	</metadata>
  <styles>
		<style name="Default">
			<fontstyle face="Tahoma" family="Tahoma" size="22" color="#7FFFFFDF" outline-color="#FF002953" outline-level="6" shadow-level="0" back-color="#7F007FFF"/>
			<position alignment="BottomCenter" vertical-margin="50%" relative-to="Window" horizontal-margin="2%"/>
		</style>
	</styles>
	<subtitles>
		<subtitle start="00:00:01.120" stop="00:00:04.265">
			<text>No fair! You changed the outcome by measuring it!</text>
		</subtitle>
  </subtitles>
</USFSubtitles>
--end-------------------------------------------------------

CodecPrivate will look like this:

--start-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- DOCTYPE USFSubtitles SYSTEM "USFV100.dtd" -->
<?xml-stylesheet type="text/xsl" href="USFV100.xsl"?>
<USFSubtitles version="1.00">
	<metadata>
	 <resolution x="640" y="480"></resolution>
	</metadata>
  <styles>
		<style name="Default">
			<fontstyle face="Tahoma" family="Tahoma" size="22" color="#7FFFFFDF" outline-color="#FF002953" outline-level="6" shadow-level="0" back-color="#7F007FFF"/>
			<position alignment="BottomCenter" vertical-margin="50%" relative-to="Window" horizontal-margin="2%"/>
		</style>
	</styles>
</USFSubtitles>
--end-------------------------------------------------------

The first <subtitle> node's corresponding block will start at
00:00:01.120, have a duration of 3s 145ms and look like this:

--start-----------------------------------------------------
<text>No fair! You changed the outcome by measuring it!</text>
--end-------------------------------------------------------

Kind regards,
mosu