📜 ⬆️ ⬇️

EBU R128 / BS.1770-3: Batch Normalization of Audio / Video File Volume

Hello!
I decided to share my experience in automating the volume control of my media. I think all profile techies have a headache for a long time, as if it continues to hurt. The recommendation introduced by the Ministry of Communications and Matters in the field of rationalization of the volume of sound signals caused disturbance waves.
No controls or means of production were provided. Spin as you wish.
However, for a long time, long before the landmark event, there are various plug-ins to the installation programs.
But what if you have already accumulated a huge media base?
image

I wandered around the Internet and came across a very, in my opinion, elegant solution. And, to my joy, it turned out to be free software. The project is called r128gain .

r128gain measures the volume of audio files in LUFS units. She understands, as far as I found out, two formats:


After the measurement, it is proposed to apply the volume to the track in two ways:
')
1. Using the SoX - Sound eXchange utility, get a combed sound:

r128gain "--command=sox %TRACK% out.wav|flac gain %TGDB%" in.wav|flac -o . 

2. Using the FFmpeg utility, replace / add an audio track to the file file:

 r128gain "--command=ffmpeg -i %TRACK% -vcodec copy -acodec flac -af volume=%TG% -y out.mkv" in.wav|flac -o. 

I chose the first option. To extract sound from my video files, I use ffmpeg:

 ffmpeg -i in.avi -vn -c:a pcm_s16le -ac 2 in.wav -y 

Normalization:

 r128gain "--command=sox %TRACK% out.wav|flac gain %TGDB%" in.wav|flac -o . 

Build the finished video file. Since in addition to old files there is a constant stream of third-party, we lead to a single format. I use this standard:

 video: MPEG2 PAL 720x576 audio: MPEG1 Layer II 

Assembly:

 ffmpeg -i in.avi -i out.wav -c:v mpeg2video -b 30000k -s pal -r pal -aspect 4:3 -vf scale=min(576*15*sar*iw/ih/16\,720):min(720*16*ih/15/sar/iw\,576),pad=720:576:(ow-iw)/2:(oh-ih)/2 -flags +ilme+ildct -movflags faststart -c:a mp2 -map 0:v:0 -map 1:a:0 out.mpg -y 

At the exit we get the product in the same format.

thanks for the help arteast arteast

Thanks for attention! I hope my article will be useful for you.

Read the second part about the implementation

Source: https://habr.com/ru/post/311758/


All Articles