fix off by one and make option to load melt outside of class

This commit is contained in:
j 2023-10-19 15:53:18 +01:00
parent 7fe4b02552
commit 73a9481ef1

View file

@ -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_),