added --normalize-override: Volume correction to use instead of computing the required value in a (lengthy) pre-pass.

This commit is contained in:
Overwatch 2014-08-29 11:24:53 +02:00
parent 3fff52fedc
commit ae18e7a6ef

View file

@ -43,7 +43,8 @@ if __name__ == '__main__':
main.add_option('video', 'str', 'x264', 'Video codec to use, either §mx264§/, §mtheora§/, §mcopy§/ or §mdrop§/.', short_name='v')
main.add_option('video-quality', 'float', 22, 'Video encoding quality. Use 0-10 for Theora (0 being the lowest, 5-7 is generally watchable) and 0-51 for x264 (0 being lossless, 18-28 is reasonable).', short_name='Q')
main.add_option('normalize', 'bool', True, 'Normalize the audio track.', short_name='n')
main.add_option('normalize-target', 'float', -20.0, 'Target mean volume to target.', short_name='N')
main.add_option('normalize-target', 'float', -20.0, 'Target mean volume to target.')
main.add_option('normalize-override', 'float', 0.0, 'Volume correction to use instead of computing the required value in a (lengthy) pre-pass.', short_name='N')
main.add_option('ffmpeg-vfilter', 'str', '', 'Raw ffmpeg -filter:v options, e.g. "scale=720:trunc(ow/a/2)*2"', short_name='f')
main.add_option('move-source', 'str', '', 'Move source file to this directory after conversion.', short_name='m')
main.add_option('dump-commands', 'bool', False, 'Print ffmpeg commands that would be executed. If §B--§gnormalize§/ is in effect, the normalization pre-pass will still be performed so that the proper volume correction can be computed.', short_name='D')
@ -68,7 +69,9 @@ if __name__ == '__main__':
if main.cfg.audio == 'vorbis':
audio_words.append('§gquality§/=§m%.1f§/' %(main.cfg.audio_quality))
if main.cfg.normalize:
if main.cfg.normalize_override != 0:
audio_words.append('§gadjust_volume§/=§m%.1f dB§/' %(main.cfg.normalize_override))
elif main.cfg.normalize:
audio_words.append('§gnormalize§/=§m%.1f dB§/' %(main.cfg.normalize_target))
if main.cfg.video in ('copy', 'drop'):
@ -177,6 +180,7 @@ if __name__ == '__main__':
# normalization pre-pass
if (main.cfg.armed or main.cfg.dump_commands) and main.cfg.normalize:
if main.cfg.normalize_override == 0.0:
_print('running normalization pre-pass')
command.normalize_prepass.reset()
@ -215,6 +219,10 @@ if __name__ == '__main__':
pb.blank()
_print('detected volume %.1f dB, correction %.1f dB' %(info.mean_volume, info.volume_correction))
else:
info.volume_correction = main.cfg.normalize_override
_print('using user-supplied volume correction %.1f dB' %(info.volume_correction))
info.normalize_command = command.sub_normalize
info.normalize_command.reset()
info.normalize_command.VOLUME = 'volume=%.2fdB' %(info.volume_correction)