Re: Storing USF subtitles in Matroska

Moritz Bunkus via Matroska-devel <[email protected]> Sun, 20 Mar 2016 19:38:50 +0100
Newsgroups gmane.comp.multimedia.matroska.devel
Message-ID <[email protected]>
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

_______________________________________________
Matroska-devel mailing list
[email protected]
http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-devel
Read Matroska-Devel on GMane: http://dir.gmane.org/gmane.comp.multimedia.matroska.devel
signature.asc (application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE-----

iQIcBAABCgAGBQJW7u46AAoJEHSvAK3y4yyFTkoQAJZdrEM3bpoiWw2JJ3/j03tk
VqumUX97f/vYmVcKudEk8sI9YT4Jp3OY6UG9Wlyz+1xRm+QhTJWv8p/8CEoybXdr
ACFvugI91GPR6mV4baCJ0snq9+eqhbJ5qlVJpNqMvnQ6MseP5eHHBH5pGH8wd4kZ
hAaIJLvCBz7Cg7GEbm/rEkv1UHKQuVo0vSOqlpXMLH6brfciPNKQd25V+3couhae
jfCU0DZhdsgnvwQkK4U5u0LKUKp5AptXeyPrXlxrjo1Da07w0nYxfG24DmG150pq
7l3WbSyeo3PbXg1DMWFDP2ZhrP4NoLIJ8/2DTlHhBudXPK9gfSOoFFxnH2wuGLrU
1ZD8Vihyxrh1KcgLIaEGLAn3gblrfb0wVPcmDAw/Pa+af8Kko8dNtD7cf54qNTe+
h9zimAoyhLVeXScZ2XylFZdrumQXU4vddNHqy9Sewqyo+m/RXsamh7/eOew/GA1L
BRfSM8wta257Rig37MTXSShg3Honcmoe2WoKBj9HAmD16bt1EE0fJEVB1tkduqtx
0Xqnme/9o7uMhYajCd+SGhH8xAxduFQw/2uCD7qPQ50ZklXXbD/q7dNqAc2QCPU2
SaVe87+ZmDBp3xWQIvosL/A+1O3TafFt2AGDtTqnO4web9omI9LQw0WPUCuzT02y
4ffX9rXkFEE3i8DS3jNs
=wrFl
-----END PGP SIGNATURE-----