From 94cf69a21cc53ec9a43058f12aa06d03af1f85b4 Mon Sep 17 00:00:00 2001 From: Antoine Van-Elstraete Date: Thu, 15 Apr 2021 15:52:51 +0200 Subject: [PATCH] Ajustement du volume --- vid_convert.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/vid_convert.py b/vid_convert.py index 3337061..cfc94ae 100755 --- a/vid_convert.py +++ b/vid_convert.py @@ -85,6 +85,25 @@ def cropping(file, infos): 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__': import argparse parser = argparse.ArgumentParser() @@ -98,3 +117,4 @@ if __name__ == '__main__': infos = get_infos(args.f_input) interlaced = is_interlaced(args.f_input, infos) cropsize = cropping(args.f_input, infos) + volumes = volume_audio(args.f_input, infos)