minor fixes
This commit is contained in:
parent
d2bc68885e
commit
9fd271351f
1 changed files with 15 additions and 5 deletions
|
@ -23,7 +23,7 @@ X264_BANNED_PIXFMTS = {'bgr24'}
|
||||||
# see doc/command_assembler.png
|
# see doc/command_assembler.png
|
||||||
command = over.core.types.ndict()
|
command = over.core.types.ndict()
|
||||||
command.identify = Command('ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', 'INFILE')
|
command.identify = Command('ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', 'INFILE')
|
||||||
command.normalize_prepass = Command('ffmpeg', '-i', 'INFILE', '-af', 'volumedetect', '-f', 'null', '/dev/null')
|
command.normalize_prepass = Command('ffmpeg', '-i', 'INFILE', '-filter:a', 'volumedetect', '-f', 'null', '/dev/null')
|
||||||
command.encode_generic = Command('ffmpeg', '-i', 'INFILE', 'VIDEO', 'AUDIO', '-sn', 'OUTFILE')
|
command.encode_generic = Command('ffmpeg', '-i', 'INFILE', 'VIDEO', 'AUDIO', '-sn', 'OUTFILE')
|
||||||
command.sub_vorbis = Command('-codec:a', 'libvorbis', '-qscale:a', 'QUALITY', 'NORMALIZE')
|
command.sub_vorbis = Command('-codec:a', 'libvorbis', '-qscale:a', 'QUALITY', 'NORMALIZE')
|
||||||
command.sub_pcm = Command('-codec:a', 'pcm_s16le', 'NORMALIZE')
|
command.sub_pcm = Command('-codec:a', 'pcm_s16le', 'NORMALIZE')
|
||||||
|
@ -250,18 +250,24 @@ if __name__ == '__main__':
|
||||||
elif out is None:
|
elif out is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
pb.end()
|
||||||
|
|
||||||
output = b''.join(output_buffer)
|
output = b''.join(output_buffer)
|
||||||
|
|
||||||
if b'mean_volume: ' in output:
|
if b'mean_volume: ' in output:
|
||||||
info.mean_volume = float(re.findall(b'mean_volume: (-\d+\.\d+) dB', output)[0])
|
info.mean_volume = float(re.findall(b'mean_volume: (-?\d+\.\d+) dB', output)[0])
|
||||||
|
info.max_correction = -float(re.findall(b'max_volume: (-?\d+\.\d+) dB', output)[0])
|
||||||
info.volume_correction = main.cfg.normalize_target - info.mean_volume
|
info.volume_correction = main.cfg.normalize_target - info.mean_volume
|
||||||
else:
|
else:
|
||||||
main.print('§runexpected ffmpeg output§/, dump follows', prefix.fail, suffix=':\n')
|
main.print('§runexpected ffmpeg output§/, dump follows', prefix.fail, suffix=':\n')
|
||||||
print(output.decode('utf-8'))
|
print(output.decode('utf-8'))
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
pb.end()
|
main.print('detected volume %.1f dB, correction %.1f dB, max. correction %.1f dB' %(info.mean_volume, info.volume_correction, info.max_correction))
|
||||||
main.print('detected volume %.1f dB, correction %.1f dB' %(info.mean_volume, info.volume_correction))
|
|
||||||
|
if info.volume_correction > info.max_correction:
|
||||||
|
d = info.volume_correction - info.max_correction
|
||||||
|
main.print("suggested correction is %.1f dB above the stream's maximum and will cause clipping" %(d), prefix.warn)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
info.volume_correction = main.cfg.normalize_override
|
info.volume_correction = main.cfg.normalize_override
|
||||||
|
@ -386,7 +392,11 @@ if __name__ == '__main__':
|
||||||
elif out is None:
|
elif out is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
pb.set("s", files.tmpfile.stat().st_size)
|
try:
|
||||||
|
pb.set("s", files.tmpfile.stat().st_size)
|
||||||
|
except FileNotFoundError: # a race condition with ffmpeg
|
||||||
|
pass
|
||||||
|
|
||||||
pb.render()
|
pb.render()
|
||||||
|
|
||||||
new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'o')
|
new_filesize = over.core.text.Unit(files.tmpfile.stat().st_size, 'o')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue