handle missing data better
This commit is contained in:
parent
d8d3636bc7
commit
f62479ad12
2 changed files with 27 additions and 15 deletions
35
render.py
35
render.py
|
|
@ -52,6 +52,7 @@ def compose(clips, target=150, base=1024, voice_over=None, options=None):
|
||||||
|
|
||||||
voice_overs = []
|
voice_overs = []
|
||||||
sub_offset = 0
|
sub_offset = 0
|
||||||
|
vo_min = 0
|
||||||
if voice_over:
|
if voice_over:
|
||||||
vo_keys = list(sorted(voice_over))
|
vo_keys = list(sorted(voice_over))
|
||||||
if chance(seq, 0.5):
|
if chance(seq, 0.5):
|
||||||
|
|
@ -163,21 +164,22 @@ def compose(clips, target=150, base=1024, voice_over=None, options=None):
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
volume = '0'
|
volume_center = volume_front = '-2.5'
|
||||||
|
volume_rear = '-8.5'
|
||||||
scene['audio-center']['A1'].append({
|
scene['audio-center']['A1'].append({
|
||||||
'duration': clip['duration'],
|
'duration': clip['duration'],
|
||||||
'src': audio,
|
'src': audio_center,
|
||||||
'filter': {'volume': cf_volume},
|
'filter': {'volume': volume},
|
||||||
})
|
})
|
||||||
scene['audio-front']['A2'].append({
|
scene['audio-front']['A2'].append({
|
||||||
'duration': clip['duration'],
|
'duration': clip['duration'],
|
||||||
'src': audio,
|
'src': audio_front,
|
||||||
'filter': {'volume': cf_volume},
|
'filter': {'volume': volume},
|
||||||
})
|
})
|
||||||
scene['audio-rear']['A2'].append({
|
scene['audio-rear']['A2'].append({
|
||||||
'duration': clip['duration'],
|
'duration': clip['duration'],
|
||||||
'src': foley,
|
'src': audio,
|
||||||
'filter': {'volume': cf_volume},
|
'filter': {'volume': volume_rear},
|
||||||
})
|
})
|
||||||
used.append(clip)
|
used.append(clip)
|
||||||
print("scene duration %0.3f (target: %0.3f, vo_min: %0.3f)" % (length, target, vo_min))
|
print("scene duration %0.3f (target: %0.3f, vo_min: %0.3f)" % (length, target, vo_min))
|
||||||
|
|
@ -304,6 +306,9 @@ def get_fragments(clips, voice_over, prefix):
|
||||||
orig = i.files.filter(selected=True).first()
|
orig = i.files.filter(selected=True).first()
|
||||||
if orig:
|
if orig:
|
||||||
ext = os.path.splitext(orig.data.path)[1]
|
ext = os.path.splitext(orig.data.path)[1]
|
||||||
|
if 'type' not in i.data:
|
||||||
|
print("FIXME", i)
|
||||||
|
continue
|
||||||
type_ = i.data['type'][0].lower()
|
type_ = i.data['type'][0].lower()
|
||||||
target = os.path.join(prefix, type_, i.data['title'] + ext)
|
target = os.path.join(prefix, type_, i.data['title'] + ext)
|
||||||
originals.append(target)
|
originals.append(target)
|
||||||
|
|
@ -368,8 +373,12 @@ def render_all(options):
|
||||||
clips_used += used
|
clips_used += used
|
||||||
scene_duration = get_scene_duration(scene)
|
scene_duration = get_scene_duration(scene)
|
||||||
print("%s %6.3f -> %6.3f (%6.3f)" % (name, target, scene_duration, fragment_target))
|
print("%s %6.3f -> %6.3f (%6.3f)" % (name, target, scene_duration, fragment_target))
|
||||||
src = [a for a in scene['audio-rear']['A1'] if 'src' in a][0]['src']
|
src = [a for a in scene['audio-rear']['A1'] if 'src' in a]
|
||||||
stats[src.split('/')[-2]] += 1
|
if src:
|
||||||
|
src = src[0]['src']
|
||||||
|
stats[src.split('/')[-2]] += 1
|
||||||
|
else:
|
||||||
|
print("!! fixme, chapter without VO")
|
||||||
|
|
||||||
position += scene_duration
|
position += scene_duration
|
||||||
target_position += fragment_target
|
target_position += fragment_target
|
||||||
|
|
@ -832,11 +841,13 @@ def generate_clips(options):
|
||||||
|
|
||||||
voice_over = defaultdict(dict)
|
voice_over = defaultdict(dict)
|
||||||
for vo in item.models.Item.objects.filter(
|
for vo in item.models.Item.objects.filter(
|
||||||
data__type__contains="Voice Over",
|
data__type__icontains="voice over",
|
||||||
):
|
):
|
||||||
fragment_id = int(vo.get('title').split('_')[0])
|
title = vo.get('title')
|
||||||
|
fragment_id = int(title.split('_')[2].replace('gen', ''))
|
||||||
source = vo.files.filter(selected=True)[0]
|
source = vo.files.filter(selected=True)[0]
|
||||||
batch = vo.get('batch')[0].replace('Text-', '')
|
#batch = vo.get('batch')[0].replace('Text-', '')
|
||||||
|
batch = title.split('_')[3]
|
||||||
src = source.data.path
|
src = source.data.path
|
||||||
target = os.path.join(prefix, 'voice_over', batch, '%s.wav' % fragment_id)
|
target = os.path.join(prefix, 'voice_over', batch, '%s.wav' % fragment_id)
|
||||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,10 @@ def get_scene_duration(scene):
|
||||||
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():
|
||||||
for clip in clips:
|
if clips:
|
||||||
duration += int(clip["duration"] * 24)
|
for clip in clips:
|
||||||
return duration / 24
|
duration += int(clip["duration"] * 24)
|
||||||
|
return duration / 24
|
||||||
|
|
||||||
|
|
||||||
def get_offset_duration(prefix):
|
def get_offset_duration(prefix):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue