kdenlive to mmg/mkv and bombono

revision e541f3481f64dc3d98cd35350ad9eddf8e1e1f67

raw

README.rst

XSLT files to convert kdenlive files to mkv chapters for mmg (mkvmerge gui), and to DVD chapters (bombono).

raw

kdenlive-to-bombono-parts.xsl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Convert kdenlive guide markers into Bombono parts
      that can be pasted into bombono xml project files.
 
      This works with kdenlive 16.12.
      Earlier versions of kdenlive were different;
      they had mlt/kdenlivedoc/guides/guide tags
      which are not generated anymore
 -->
 <xsl:output indent="yes"/>
 
 <xsl:template match="/">
  <Parts>
    <xsl:for-each select="mlt/playlist/property[substring(@name, 0, 16) = 'kdenlive:guide.']">
      <!-- we need to sort manually, they can appear in any order -->
      <xsl:sort data-type="number" select="translate(substring(@name, 16),',','.')"/>
 
      <xsl:variable name="timeorig" select="substring(@name, 16)"/>
      <!-- support german files with comma as decimal separator-->
      <xsl:variable name="time" select="translate($timeorig,',','.')"/>
 
      <Part>
        <xsl:attribute name="Name"><xsl:value-of select="."/></xsl:attribute>
        <xsl:value-of select="$time"/>
      </Part>
    </xsl:for-each>
  </Parts>
 </xsl:template>
 
</xsl:stylesheet> 
raw

kdenlive-to-mkv-chapters.xsl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Convert kdenlive guide markers into MKV chapters.
 
      this works with kdenlive 17.07.70.
      Earlier versions were different.
 -->
 <xsl:output indent="yes"/>
 
 <xsl:template match="/">
  <Chapters>
   <EditionEntry>
      <xsl:for-each select="mlt/playlist/property[substring(@name, 0, 16) = 'kdenlive:guide.']">
        <!-- we need to sort manually, they can appear in any order -->
        <xsl:sort data-type="number" select="substring-before(concat(translate(substring(@name, 16),'.',''),','),',')"/>
 
        <xsl:variable name="timeorig" select="substring(@name, 16)"/>
        <!-- remove sub-seconds "2.652,56" -->
        <xsl:variable name="time"
                      select="substring-before(
                                concat(
                                  translate(
                                    substring(@name, 16),
                                    '.', 
                                    ''
                                  ),
                                  ','
                                ),
                                ','
                              )"/>
 
        <xsl:variable name="seconds" select="$time mod 60" />
        <xsl:variable name="minutes" select="floor($time div 60) mod 60" />
        <xsl:variable name="hours" select="floor(($time div 60) div 60)" />
        <!-- hh:mm:ss.msec -->
        <xsl:variable name="timecode">
          <xsl:value-of select="format-number($hours, '00')"/>
          <xsl:text>:</xsl:text>
          <xsl:value-of select="format-number($minutes, '00')"/>
          <xsl:text>:</xsl:text>
          <xsl:value-of select="format-number($seconds, '00.000')"/>
        </xsl:variable>
           
        <ChapterAtom>
          <ChapterDisplay>
            <ChapterString>
              <xsl:if test=".!='Hilfslinie'">
                <xsl:value-of select="."/>
              </xsl:if>
            </ChapterString>
            <ChapterLanguage>ger</ChapterLanguage>
          </ChapterDisplay>
          <ChapterFlagHidden>
            <xsl:choose>
              <xsl:when test=".='Hilfslinie'">1</xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </ChapterFlagHidden>
          <ChapterFlagEnabled>1</ChapterFlagEnabled>
          <ChapterTimeStart>
            <xsl:value-of select="$timecode"/>
          </ChapterTimeStart>
        </ChapterAtom>
      </xsl:for-each>
 
   </EditionEntry>
  </Chapters>
 </xsl:template>
 
</xsl:stylesheet> 
 

History