Have you ever needed to take the chapters from an MKV file, and display them in a non-linear editor like Vegas or Premiere? I did, so I came up with a script for this problem.
Scripts are at the end, only requirements are MKVCleaver and Python3. This will also work on Sony Vegas, or any other NLE that allows you to import an SRT file.
Step 1 Run your MKV files through MKVCleaver, and export only the Chapters. You'll get XML files doing it this way.
Step 2 Drag/drop those XML files onto the .bat script below
Step 3 Import the SRT file into your NLE as a captions file. And that's it!
As always, remember that file names matter, especially the Python one, and these two scripts have to be in the same folder with your XML.
Drop XMLs here to convert chapters to SRT.bat
MKVCleaver Chapters XML to SRT.pyCode:@echo off FOR %%A IN (%*) DO ( python3 "MKVCleaver Chapters XML to SRT.py" "%%~nA" )
Code:import sys import xml.etree.ElementTree as ET xmlfile = (sys.argv[1]+".xml") tree = ET.parse(xmlfile) root = tree.getroot() text ="" chapters = list() loopnum=0 for elm in root.findall(".//ChapterTimeStart"): rawstarttime=str(elm.text[:12]) starttime= rawstarttime.replace(".",",") hrs=int(starttime[0:2]) mins=int(starttime[3:5]) secs=int(starttime[6:8]) ms=int(starttime[9:12]) chap = starttime chapters.append(chap) for i in range (len(chapters)): chap = chapters[i] start = chapters[i] try: end = chapters[i+1] except IndexError: end = start loopnum+=1 text += f"""{loopnum} {start} --> {end} Chapter {loopnum} """ print(text) with open(sys.argv[1]+".srt", "a") as myfile: myfile.write(text)
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 1 of 1
Thread
-
Last edited by seanmcnally; 23rd Jan 2022 at 16:05. Reason: clearer wording
Similar Threads
-
extracting hard coded subtitles to a srt format using videosubfinder
By jraju in forum Newbie / General discussionsReplies: 4Last Post: 7th Feb 2022, 08:24 -
Embedding Premiere Pro markers inside an MP4 file as chapters
By seanmcnally in forum EditingReplies: 0Last Post: 29th Sep 2021, 14:17 -
Best way to add mkv and ac3 or dts in Adobe Premiere Pro
By m00511 in forum Newbie / General discussionsReplies: 2Last Post: 28th Jan 2020, 20:14 -
Should I uninstall Vegas Pro 14 before installing Vegas Pro 15?
By hbenthow in forum EditingReplies: 5Last Post: 18th Dec 2018, 21:34 -
Vegas Pro and AC3 and MKV?
By hurricane1951 in forum Authoring (DVD)Replies: 0Last Post: 6th Aug 2017, 00:52