adjust volume for stereo_downmix

This commit is contained in:
j 2025-05-21 13:17:50 +01:00
commit 34b111c343

View file

@ -69,7 +69,9 @@ def write_if_new(path, data, mode=''):
def format_duration(duration, fps): def format_duration(duration, fps):
return float('%0.5f' % (round(duration * fps) / fps)) return float('%0.5f' % (round(duration * fps) / fps))
def compose(clips, target=150, base=1024, voice_over=None): def compose(clips, target=150, base=1024, voice_over=None, options=None):
if options is None:
options = {}
fps = 24 fps = 24
length = 0 length = 0
scene = { scene = {
@ -149,6 +151,18 @@ def compose(clips, target=150, base=1024, voice_over=None):
a, b = '-9.5', '-1.50' a, b = '-9.5', '-1.50'
elif 'Melody' in voc['src']: elif 'Melody' in voc['src']:
a, b = '-5.25', '-0.25' a, b = '-5.25', '-0.25'
if options.get('stereo_downmix'):
a, b = '-9', '-1'
if 'Whispered' in voc['src']:
a, b = '-6', '2'
elif 'Read' in voc['src']:
a, b = '-5.75', '2.25'
elif 'Free' in voc['src']:
a, b = '-6.8', '3.2'
elif 'Ashley' in voc['src']:
a, b = '-7.5', '0.50'
elif 'Melody' in voc['src']:
a, b = '-3.25', '1.75'
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()
@ -285,10 +299,13 @@ def compose(clips, target=150, base=1024, voice_over=None):
blur = seq() * 3 blur = seq() * 3
if blur: if blur:
scene['back']['V1'][-1]['filter']['blur'] = blur scene['back']['V1'][-1]['filter']['blur'] = blur
volume_back = '-8.2'
if options.get('stereo_downmix'):
volume_back = '-6.2'
scene['audio-back']['A1'].append({ scene['audio-back']['A1'].append({
'duration': clip['duration'], 'duration': clip['duration'],
'src': clip['original'], 'src': clip['original'],
'filter': {'volume': '-8.2'}, 'filter': {'volume': volume_back},
}) })
# TBD: Foley # TBD: Foley
cf_volume = '-2.5' cf_volume = '-2.5'
@ -498,7 +515,13 @@ def render_all(options):
fragment_clips = fragment['clips'] fragment_clips = fragment['clips']
unused_fragment_clips = [c for c in fragment_clips if c not in clips_used] unused_fragment_clips = [c for c in fragment_clips if c not in clips_used]
print('fragment clips', len(fragment_clips), 'unused', len(unused_fragment_clips)) print('fragment clips', len(fragment_clips), 'unused', len(unused_fragment_clips))
scene, used = compose(unused_fragment_clips, target=target, base=fragment_base, voice_over=fragment['voice_over']) scene, used = compose(
unused_fragment_clips,
target=target,
base=fragment_base,
voice_over=fragment['voice_over'],
options=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))