From 73a9481ef19bc6aa36a78ad91ddc5b952ba68e67 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 15:53:18 +0100 Subject: [PATCH] fix off by one and make option to load melt outside of class --- render_kdenlive.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/render_kdenlive.py b/render_kdenlive.py index 53c6b07..726550c 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -12,6 +12,12 @@ def get_propery(element, name): return element.xpath('property[@name="%s"]' % name)[0].text +def melt_xml(file): + if file in _CACHE: + out = _CACHE[file] + else: + out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode() + return out class KDEnliveProject: @@ -423,10 +429,7 @@ class KDEnliveProject: return prefix + self.get_counter(prefix) def get_chain(self, file, kdenlive_id=None): - if file in _CACHE: - out = _CACHE[file] - else: - out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode() + out = melt_xml(file) chain = lxml.etree.fromstring(out).xpath('producer')[0] chain.tag = 'chain' chain.attrib['id'] = self.get_id('chain') @@ -614,7 +617,7 @@ class KDEnliveProject: self.get_element("entry", attrib={ "producer": chain.attrib["id"], "in": chain.attrib["in"], - "out": str(frames), + "out": str(frames - 1) }, children=[ ["kdenlive:id", id], ] + filters_),