From c47e6a5e15b0d53ec127f1b6aa6201e328ed561f Mon Sep 17 00:00:00 2001 From: j Date: Mon, 26 Jan 2026 18:34:55 +0100 Subject: [PATCH] source material might not be in same fps, import with profile --- render_kdenlive.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/render_kdenlive.py b/render_kdenlive.py index 1cdc6b3..245d8aa 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -21,7 +21,7 @@ def get_melt(): cmd = ['xvfb-run', '-a'] + cmd return cmd -def melt_xml(file): +def melt_xml(file, profile='atsc_1080p_24'): out = None real_path = os.path.realpath(file) if file in _CACHE and isinstance(_CACHE[file], list): @@ -29,7 +29,7 @@ def melt_xml(file): if os.stat(real_path).st_mtime != ts: out = None if not out: - cmd = get_melt() + [file, '-consumer', 'xml'] + cmd = get_melt() + [file, '-profile', profile, '-consumer', 'xml'] out = subprocess.check_output(cmd).decode() _CACHE[file] = [os.stat(real_path).st_mtime, out] return out @@ -73,6 +73,7 @@ class KDEnliveProject: self._width = int(width) self._height = int(height) self._fps = int(frame_rate_num) / int(frame_rate_den) + self.profile = 'atsc_1080p_24' self._tree = self.get_element("mlt", attrib={ "LC_NUMERIC": "C", @@ -444,7 +445,7 @@ class KDEnliveProject: return prefix + self.get_counter(prefix) def get_chain(self, file, kdenlive_id=None): - out = melt_xml(file) + out = melt_xml(file, self.profile) chain = lxml.etree.fromstring(out).xpath('producer')[0] chain.tag = 'chain' chain.attrib['id'] = self.get_id('chain') @@ -597,7 +598,11 @@ class KDEnliveProject: else: print('!!', track_id) - frames = int(self._fps * clip['duration']) + frames = int(round(self._fps * clip['duration'])) + if track_id[0] == "V": + if abs(self._fps * clip['duration'] - frames) > 1/48: + delta = abs(self._fps * clip['duration'] - frames) * 24 + print("Track alignment issues", self._fps * clip['duration'], frames, clip.get('src', clip), delta) self._duration[track_id] += frames if clip.get("blank"):