Ajustement du volume

This commit is contained in:
Antoine Van Elstraete 2021-04-15 15:52:51 +02:00
parent e0e747ab04
commit 94cf69a21c

View File

@ -85,6 +85,25 @@ def cropping(file, infos):
return cropsize return cropsize
def volume_audio(file, infos):
'''
Cette fonction ajuste le volume vers 0dB
'''
volumes = {}
for piste_audio in infos['audio']:
piste = piste_audio['index']
command = f"ffmpeg -loglevel info -i {file} -map 0:{piste} -af volumedetect -f null -y /dev/null"
volumedetect = subprocess.getoutput(command)
for line in volumedetect.splitlines():
if "max_volume" in line:
volume = line.split()[-2]
volume = f"{str(-float(volume))}dB"
logging.debug(f"Ajustement du volume de la piste {piste} : {volume}")
volumes.update({piste: volume})
return volumes
if __name__ == '__main__': if __name__ == '__main__':
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -98,3 +117,4 @@ if __name__ == '__main__':
infos = get_infos(args.f_input) infos = get_infos(args.f_input)
interlaced = is_interlaced(args.f_input, infos) interlaced = is_interlaced(args.f_input, infos)
cropsize = cropping(args.f_input, infos) cropsize = cropping(args.f_input, infos)
volumes = volume_audio(args.f_input, infos)