render fixes, encode vides in render command
This commit is contained in:
parent
e84ea31147
commit
5075394318
4 changed files with 35 additions and 7 deletions
14
render.py
14
render.py
|
|
@ -14,7 +14,9 @@ def random_choice(seq, items, pop=False):
|
|||
n = n_ = len(items) - 1
|
||||
#print('len', n)
|
||||
if n == 0:
|
||||
return items[0]
|
||||
if pop:
|
||||
return items.pop(n)
|
||||
return items[n]
|
||||
r = seq()
|
||||
base = 10
|
||||
while n > 10:
|
||||
|
|
@ -50,9 +52,12 @@ def compose(clips, target=150, base=1024):
|
|||
'A4': [],
|
||||
}
|
||||
}
|
||||
all_clips = clips.copy()
|
||||
seq = random(base)
|
||||
while target - length > 10 and clips:
|
||||
clip = random_choice(seq, clips, True)
|
||||
if not clips:
|
||||
clips = [c for c in all_clips if c != clip]
|
||||
if length + clip['duration'] > target:
|
||||
break
|
||||
length += clip['duration']
|
||||
|
|
@ -112,6 +117,7 @@ def compose(clips, target=150, base=1024):
|
|||
|
||||
def render(root, scene, prefix=''):
|
||||
fps = 24
|
||||
files = []
|
||||
for timeline, data in scene.items():
|
||||
print(timeline)
|
||||
project = KDEnliveProject(root)
|
||||
|
|
@ -121,6 +127,8 @@ def render(root, scene, prefix=''):
|
|||
print(track)
|
||||
for clip in clips:
|
||||
project.append_clip(track, clip)
|
||||
|
||||
with open(os.path.join(root, prefix + "%s.kdenlive" % timeline), 'w') as fd:
|
||||
path = os.path.join(root, prefix + "%s.kdenlive" % timeline)
|
||||
with open(path, 'w') as fd:
|
||||
fd.write(project.to_xml())
|
||||
files.append(path)
|
||||
return files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue