Compare commits
3 commits
74b1b57951
...
86dc72ec01
| Author | SHA1 | Date | |
|---|---|---|---|
| 86dc72ec01 | |||
| eaf95133d6 | |||
| 94632c550d |
1 changed files with 12 additions and 31 deletions
43
render.py
43
render.py
|
|
@ -118,14 +118,6 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
||||||
clips = selected_clips
|
clips = selected_clips
|
||||||
clip = None
|
clip = None
|
||||||
while target - length > 0 and clips:
|
while target - length > 0 and clips:
|
||||||
'''
|
|
||||||
if clip:
|
|
||||||
if chance(seq, 0.5):
|
|
||||||
next_seqid = clip['seqid'] + 1
|
|
||||||
clip = get_clip_by_seqid(clips, next_seqid)
|
|
||||||
else:
|
|
||||||
clip = None
|
|
||||||
'''
|
|
||||||
clip = None
|
clip = None
|
||||||
if not clip:
|
if not clip:
|
||||||
# FIXME: while not all clips have AI versions make sure we have one 50% of the time
|
# FIXME: while not all clips have AI versions make sure we have one 50% of the time
|
||||||
|
|
@ -161,7 +153,7 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
volume_front = '-17'
|
volume_front = '-15'
|
||||||
if clip.get('volume') is not None:
|
if clip.get('volume') is not None:
|
||||||
volume_front = '%0.2f' % (float(volume_front) + clip['volume'])
|
volume_front = '%0.2f' % (float(volume_front) + clip['volume'])
|
||||||
|
|
||||||
|
|
@ -271,9 +263,9 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
||||||
print('%07.3f-%07.3f %07.3f' % (sub_offset, sub_offset+vo["duration"], vo["duration"]), vo["src"].split('/')[-1])
|
print('%07.3f-%07.3f %07.3f' % (sub_offset, sub_offset+vo["duration"], vo["duration"]), vo["src"].split('/')[-1])
|
||||||
voice_overs.append(vo)
|
voice_overs.append(vo)
|
||||||
voc = vo.copy()
|
voc = vo.copy()
|
||||||
a, b = '0', '0'
|
a, b = '5', '-1'
|
||||||
if options.get('stereo_downmix'):
|
if options.get('stereo_downmix'):
|
||||||
a, b = '0', '0'
|
a, b = '5', '-1'
|
||||||
voc['filter'] = {'volume': a}
|
voc['filter'] = {'volume': a}
|
||||||
scene['audio-center']['A1'].append(voc)
|
scene['audio-center']['A1'].append(voc)
|
||||||
vo_low = vo.copy()
|
vo_low = vo.copy()
|
||||||
|
|
@ -458,7 +450,7 @@ def get_fragments(clips, voice_over, prefix):
|
||||||
print("FIXME", i)
|
print("FIXME", i)
|
||||||
continue
|
continue
|
||||||
type_ = i.data['type'][0].lower()
|
type_ = i.data['type'][0].lower()
|
||||||
target = os.path.join(prefix, 'video', type_, i.data['title'] + ext)
|
target = os.path.join(prefix, 'video', type_, "%s-%s%s" % (i.data['title'], i.public_id, ext))
|
||||||
sources.append(target)
|
sources.append(target)
|
||||||
fragment['clips'] = []
|
fragment['clips'] = []
|
||||||
for clip in clips:
|
for clip in clips:
|
||||||
|
|
@ -964,6 +956,9 @@ def generate_clips(options):
|
||||||
not_yet = itemlist.models.List.objects.filter(name='Not yet').first()
|
not_yet = itemlist.models.List.objects.filter(name='Not yet').first()
|
||||||
if not_yet:
|
if not_yet:
|
||||||
skip += [i.public_id for i in not_yet.get_items(not_yet.user).all()]
|
skip += [i.public_id for i in not_yet.get_items(not_yet.user).all()]
|
||||||
|
if skip:
|
||||||
|
skip = list(set(skip))
|
||||||
|
print("skipping %s clips" % len(skip))
|
||||||
for i in item.models.Item.objects.filter(sort__type='source'):
|
for i in item.models.Item.objects.filter(sort__type='source'):
|
||||||
if i.public_id in skip:
|
if i.public_id in skip:
|
||||||
continue
|
continue
|
||||||
|
|
@ -997,7 +992,7 @@ def generate_clips(options):
|
||||||
ai_type = '%s-%s' % (type_[3:], n)
|
ai_type = '%s-%s' % (type_[3:], n)
|
||||||
n += 1
|
n += 1
|
||||||
type_ = 'ai:' + ai_type
|
type_ = 'ai:' + ai_type
|
||||||
target = os.path.join(prefix, 'video', type_, i.data['title'] + ext)
|
target = os.path.join(prefix, 'video', type_, "%s-%s%s" % (i.data['title'], i.public_id, ext))
|
||||||
if ai_type:
|
if ai_type:
|
||||||
clip['ai'][ai_type] = target
|
clip['ai'][ai_type] = target
|
||||||
if type_ == "source":
|
if type_ == "source":
|
||||||
|
|
@ -1030,22 +1025,6 @@ def generate_clips(options):
|
||||||
if adjust_volume:
|
if adjust_volume:
|
||||||
clip['volume'] = float(adjust_volume)
|
clip['volume'] = float(adjust_volume)
|
||||||
clip['id'] = i.public_id
|
clip['id'] = i.public_id
|
||||||
name = os.path.basename(source_target)
|
|
||||||
seqid = re.sub(r"Hotel Aporia_(\d+)", "S\\1_", name)
|
|
||||||
seqid = re.sub(r"Night March_(\d+)", "S\\1_", seqid)
|
|
||||||
seqid = re.sub(r"_(\d+)H_(\d+)", "_S\\1\\2_", seqid)
|
|
||||||
seqid = seqid.split('_')[:2]
|
|
||||||
seqid = [b[1:] if b[:1] in ('B', 'S') else '0' for b in seqid]
|
|
||||||
seqid[1] = resolve_roman(seqid[1])
|
|
||||||
seqid[1] = ''.join([b for b in seqid[1] if b.isdigit()])
|
|
||||||
if not seqid[1]:
|
|
||||||
seqid[1] = '0'
|
|
||||||
try:
|
|
||||||
clip['seqid'] = int(''.join(['%06d' % int(b) for b in seqid]))
|
|
||||||
except:
|
|
||||||
print(name, seqid, 'failed')
|
|
||||||
raise
|
|
||||||
|
|
||||||
clips.append(clip)
|
clips.append(clip)
|
||||||
|
|
||||||
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
|
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
|
||||||
|
|
@ -1066,7 +1045,7 @@ def generate_clips(options):
|
||||||
source = vo.files.filter(selected=True)[0]
|
source = vo.files.filter(selected=True)[0]
|
||||||
src = source.data.path
|
src = source.data.path
|
||||||
ext = src.split('.')[-1]
|
ext = src.split('.')[-1]
|
||||||
target = os.path.join(prefix, 'voice_over', fragment, '%s-%s.%s' % (type, variant, ext))
|
target = os.path.join(prefix, 'voice_over', fragment, '%s-%s-%s.%s' % (type, variant, vo.public_id, ext))
|
||||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||||
if os.path.islink(target):
|
if os.path.islink(target):
|
||||||
os.unlink(target)
|
os.unlink(target)
|
||||||
|
|
@ -1096,7 +1075,7 @@ def generate_clips(options):
|
||||||
if ai:
|
if ai:
|
||||||
ai_source = ai.files.filter(selected=True)[0]
|
ai_source = ai.files.filter(selected=True)[0]
|
||||||
ai_src = ai_source.data.path
|
ai_src = ai_source.data.path
|
||||||
ai_target = os.path.join(prefix, 'voice_video', fragment, '%s-%s.%s' % (type, variant, 'mp4'))
|
ai_target = os.path.join(prefix, 'voice_video', fragment, '%s-%s-%s.%s' % (type, variant, ai.public_id, 'mp4'))
|
||||||
os.makedirs(os.path.dirname(ai_target), exist_ok=True)
|
os.makedirs(os.path.dirname(ai_target), exist_ok=True)
|
||||||
if os.path.islink(ai_target):
|
if os.path.islink(ai_target):
|
||||||
os.unlink(ai_target)
|
os.unlink(ai_target)
|
||||||
|
|
@ -1219,6 +1198,8 @@ def fragment_statistics():
|
||||||
not_yet = itemlist.models.List.objects.filter(name='Not yet').first()
|
not_yet = itemlist.models.List.objects.filter(name='Not yet').first()
|
||||||
if not_yet:
|
if not_yet:
|
||||||
skip += [i.public_id for i in not_yet.get_items(not_yet.user).all()]
|
skip += [i.public_id for i in not_yet.get_items(not_yet.user).all()]
|
||||||
|
if skip:
|
||||||
|
skip = list(set(skip))
|
||||||
|
|
||||||
for l in itemlist.models.List.objects.filter(status='featured').order_by('name'):
|
for l in itemlist.models.List.objects.filter(status='featured').order_by('name'):
|
||||||
if l.name.split(' ')[0].isdigit():
|
if l.name.split(' ')[0].isdigit():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue