Skip to content

Instantly share code, notes, and snippets.

@ttsuki
Created July 3, 2017 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttsuki/9faa88e1d3aad2b474ab78c1ba4fabe0 to your computer and use it in GitHub Desktop.
Save ttsuki/9faa88e1d3aad2b474ab78c1ba4fabe0 to your computer and use it in GitHub Desktop.
mkvextract chapters "hogefugapiyo.mkv" | xsltproc mkv2cue.xslt -
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="Shift_JIS"/>
<xsl:template match="/">
<xsl:text>FILE "alltrack.wav" WAVE&#xA;</xsl:text>
<xsl:apply-templates select="//ChapterAtom" />
</xsl:template>
<xsl:template match="ChapterAtom">
<xsl:text> TRACK </xsl:text><xsl:value-of select="format-number(count(preceding-sibling::ChapterAtom) + 1, '00')" /><xsl:text>&#xA;</xsl:text>
<xsl:text> TITLE "</xsl:text><xsl:value-of select="ChapterDisplay/ChapterString" /><xsl:text>"&#xA;</xsl:text>
<xsl:text> INDEX 01 </xsl:text><xsl:value-of select="format-number(number(substring(ChapterTimeStart, 1, 2)) * 60 + number(substring(ChapterTimeStart, 4, 2)), '00')"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(ChapterTimeStart, 7, 2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="format-number(number('0' + substring(ChapterTimeStart, 9)) * 75, '00')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment