Skip to content

Draft: [GSoC 2024] demux: Integrate Interactive MKV

Khalid Masum requested to merge Labnann/vlc:interactive-mkv into master

Implement the new MKV specifications that introduced MatroskaJS. This will introduce the interactive MKV playback.

Here is a sample chapter.xml file. You can use MKVToolNix or similar tool to create an MKV file to test these features:

<?xml version="1.0"?>
<!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
<Chapters>
  <EditionEntry>
    <EditionFlagOrdered>1</EditionFlagOrdered>
    <EditionUID>10557460986751345252</EditionUID>
    <ChapterAtom>
      <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:00:05.000000000</ChapterTimeEnd>
      <ChapterUID>5194952154627880090</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 01</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterProcess>
        <ChapterProcessCodecID>2</ChapterProcessCodecID>
        <ChapterProcessCommand>
          <ChapterProcessTime>1</ChapterProcessTime>
          <ChapterProcessData format="ascii">
            LogMsg("Hello World 1 EEEE");
            LogMsg("Hello World 2");
            LogMsg("Hello World 3");
            LogMsg("Hello World 4");
            AddChoice("c1g", "group1");
            AddChoice("c2g", "group1");
            AddChoice("c3g", "group2");
            AddChoice("c4g", "group2");
            AddChoice("c5", "group3");
            AddChoice("c6g", "group1");
            AddChoice("c7");
            AddChoice("c8");
            LogMsg("Finished AddChoice");
            SetChoiceText("c1g", "Continue", "en");
            SetChoiceText("c2g", "Jump", "en");
            SetChoiceText("c3g", "Choice 3!", "en");
            SetChoiceDefault("c1g", "group1");
            LogMsg("Finished SetChoiceText");
            CommitChoices();
            LogMsg("Finsihed CommitChoices");
            //GotoAndPlay("8931792216749359896");
          </ChapterProcessData>
        </ChapterProcessCommand>
      </ChapterProcess>
      <ChapterProcess>
        <ChapterProcessCodecID>2</ChapterProcessCodecID>
        <ChapterProcessCommand>
          <ChapterProcessTime>2</ChapterProcessTime>
          <ChapterProcessData format="ascii">
            LogMsg("Reading Choice....");
            choice = GetChoice("group1");
            LogMsg("Selected choice: "+choice);
            if (choice === "c2g") GotoAndPlay("3381520875822683357");
          </ChapterProcessData>
        </ChapterProcessCommand>
      </ChapterProcess>
      <ChapterTimeStart>00:00:05.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:00:10.000000000</ChapterTimeEnd>
      <ChapterUID>3537150726504939576</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 02</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:00:10.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:03:10.000000000</ChapterTimeEnd>
      <ChapterUID>1001</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 2.5</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:03:10.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:03:15.000000000</ChapterTimeEnd>
      <ChapterUID>3381520875822683357</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 03</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:03:15.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:03:25.000000000</ChapterTimeEnd>
      <ChapterUID>8931792216749359896</ChapterUID>
      <ChapterProcess>
        <ChapterProcessCodecID>2</ChapterProcessCodecID>
        <ChapterProcessCommand>
          <ChapterProcessTime>1</ChapterProcessTime>
          <ChapterProcessData format="ascii">
            LogMsg("Adding Choices");
            AddChoice("c1g", "group1");
            AddChoice("c2g", "group1");
            AddChoice("c3g", "group2");
            LogMsg("Finished AddChoice");
            SetChoiceText("c1g", "Restart!", "en");
            SetChoiceText("c2g", "Continue", "en");
            SetChoiceText("c3g", "Choice", "en");
            SetChoiceDefault("c1g", "group1");
            LogMsg("Finished SetChoiceText");
            CommitChoices();
            LogMsg("Finsihed CommitChoices");
            //GotoAndPlay("8931792216749359896");
          </ChapterProcessData>
        </ChapterProcessCommand>
      </ChapterProcess>
      <ChapterProcess>
        <ChapterProcessCodecID>2</ChapterProcessCodecID>
        <ChapterProcessCommand>
          <ChapterProcessTime>2</ChapterProcessTime>
          <ChapterProcessData format="ascii">
            LogMsg("Reading Choice....");
            var choice = GetChoice("group1");
            LogMsg("Selected choice: "+choice);
            if (choice === "c1g") GotoAndPlay("5194952154627880090");
          </ChapterProcessData>
        </ChapterProcessCommand>
      </ChapterProcess>
      <ChapterDisplay>
        <ChapterString>Chapter 04</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:03:25.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:04:20.000000000</ChapterTimeEnd>
      <ChapterUID>1002</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 4.5</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
    <ChapterAtom>
      <ChapterTimeStart>00:04:20.000000000</ChapterTimeStart>
      <ChapterTimeEnd>00:05:25.000000000</ChapterTimeEnd>
      <ChapterUID>14925502364269421373</ChapterUID>
      <ChapterDisplay>
        <ChapterString>Chapter 05</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
    </ChapterAtom>
  </EditionEntry>
</Chapters>

!5619

Edited by Khalid Masum

Merge request reports