diff --git a/render.py b/render.py index 84b3731..085a802 100644 --- a/render.py +++ b/render.py @@ -52,6 +52,7 @@ def compose(clips, target=150, base=1024, voice_over=None, options=None): voice_overs = [] sub_offset = 0 + vo_min = 0 if voice_over: vo_keys = list(sorted(voice_over)) 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({ 'duration': clip['duration'], - 'src': audio, - 'filter': {'volume': cf_volume}, + 'src': audio_center, + 'filter': {'volume': volume}, }) scene['audio-front']['A2'].append({ 'duration': clip['duration'], - 'src': audio, - 'filter': {'volume': cf_volume}, + 'src': audio_front, + 'filter': {'volume': volume}, }) scene['audio-rear']['A2'].append({ 'duration': clip['duration'], - 'src': foley, - 'filter': {'volume': cf_volume}, + 'src': audio, + 'filter': {'volume': volume_rear}, }) used.append(clip) 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() if orig: ext = os.path.splitext(orig.data.path)[1] + if 'type' not in i.data: + print("FIXME", i) + continue type_ = i.data['type'][0].lower() target = os.path.join(prefix, type_, i.data['title'] + ext) originals.append(target) @@ -368,8 +373,12 @@ def render_all(options): clips_used += used scene_duration = get_scene_duration(scene) 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'] - stats[src.split('/')[-2]] += 1 + src = [a for a in scene['audio-rear']['A1'] if 'src' in a] + if src: + src = src[0]['src'] + stats[src.split('/')[-2]] += 1 + else: + print("!! fixme, chapter without VO") position += scene_duration target_position += fragment_target @@ -832,11 +841,13 @@ def generate_clips(options): voice_over = defaultdict(dict) 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] - batch = vo.get('batch')[0].replace('Text-', '') + #batch = vo.get('batch')[0].replace('Text-', '') + batch = title.split('_')[3] src = source.data.path target = os.path.join(prefix, 'voice_over', batch, '%s.wav' % fragment_id) os.makedirs(os.path.dirname(target), exist_ok=True) diff --git a/render_utils.py b/render_utils.py index ecffdda..f90862d 100644 --- a/render_utils.py +++ b/render_utils.py @@ -63,9 +63,10 @@ def get_scene_duration(scene): duration = 0 for key, value in scene.items(): for name, clips in value.items(): - for clip in clips: - duration += int(clip["duration"] * 24) - return duration / 24 + if clips: + for clip in clips: + duration += int(clip["duration"] * 24) + return duration / 24 def get_offset_duration(prefix):