I tried to normalize some audio files using FFMPEG Loudnorm as described here.
However, in Python, I don't understand how to read data info from 1st pass.
My code:
getLoud = subprocess.Popen(f"ffmpeg -i {file_path} -filter:a loudnorm=print_format=json -f null NULL", shell=True, stdout=subprocess.PIPE).stdout
getLoud = getLoud.read().decode()
# parse json_str:
jsonstr_loud = json.loads(getLoud)
This gives me "errorMessage": "Expecting value: line 1 column 1 (char 0)"
I tried also this:
os.system(f"ffmpeg -i {file_path} -filter:a loudnorm=print_format=json -f null NULL")
and it outputs:
ffmpeg version N-60236-gffb000fff8-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2022 the FFmpeg developers...
...
[Parsed_loudnorm_0 @ 0x5921940]
{
"input_i" : "-9.33",
"input_tp" : "-0.63",
"input_lra" : "0.60",
"input_thresh" : "-19.33",
"output_i" : "-24.08",
"output_tp" : "-15.40",
"output_lra" : "0.60",
"output_thresh" : "-34.08",
"normalization_type" : "dynamic",
"target_offset" : "0.08"
}
In Python, how can I use those parameters, such as input_i, input_tp etc. that I need for the 2nd pass?
I can't use ffmpeg-normalize because I'm using FFMPEG as a Layer in Lambda.