fix scene duration

This commit is contained in:
j 2026-01-26 18:34:27 +01:00
commit 0c4f55006d

View file

@ -5,6 +5,7 @@ import lxml.etree
import ox import ox
from .render_kdenlive import melt_xml from .render_kdenlive import melt_xml
from .utils import format_duration
def parse_lang(lang): def parse_lang(lang):
@ -57,17 +58,20 @@ def get_clip_by_seqid(clips, seqid):
return None return None
def get_scene_duration(scene): def get_scene_duration(scene, fps=24, track=None):
if isinstance(scene, str): if isinstance(scene, str):
with open(scene) as fd: with open(scene) as fd:
scene = json.load(fd) scene = json.load(fd)
duration = 0 duration = 0
for key, value in scene.items(): for key, value in scene.items():
for name, clips in value.items(): for name, clips in value.items():
if track and '%s:%s' % (key, name) != track:
continue
if clips: if clips:
for clip in clips: for clip in clips:
duration += int(clip["duration"] * 24) duration += round(clip["duration"] * fps)
return duration / 24 #print("scene duration based on %s:%s is %s %s" % (key, name, duration / fps, format_duration(duration / fps, fps)))
return duration / fps
def get_offset_duration(prefix): def get_offset_duration(prefix):