You are not logged in.
I have a large batch of MP4s (hundreds of files) for which I'd like to normalise the audio. I'm currently using the following script, but it re-encodes the audio, which I know is a lossy process. Knowing that the original audio stream for each of the MP4s is 2-channel, 32-bit, 48 kHz MPEG AAC Audio, is there a cleaner method I can use which would not actually re-encode the audio? I should mention that I do want the final product to also be similar AAC audio rather than something like WAV or FLAC, to keep the file size reasonable.
for f in *.mp4 ; do
ffmpeg -i "$f" -map 0:1 -vn audio.wav
sox audio.wav audio_normalised.wav norm -3
rm audio.wav
ffmpeg -i "$f" -i audio_normalised.wav -c:v copy -map 0:v:0 -map 1:a:0 new.mp4
rm audio_normalised.wav
mv new.mp4 "$f"
done
Offline
Use ReplayGain tagging, e.g. with https://github.com/Moonbase59/loudgain
Of course then you also need to use a player that recognizes those tags.
Last edited by Morn (2021-09-27 12:56:28)
Offline
Offline
Have you tried https://superuser.com/a/323127 option 3?
Offline
Have you tried https://superuser.com/a/323127 option 3?
Option 3 re-encodes the audio.
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
Audio, is there a cleaner method I can use which would not actually re-encode the audio?
Use the ability of a media player to change it during playback
Examples:
mplayer -af equalizer=0:0:0:0:0:0:0:0:12:12 file.mp4
mpv −−af=equalizer=0:0:0:0:0:0:0:0:12:12 file.mp4
ffplay -af "equalizer=f=100:width_type=o:width=20:g=15" file.mp4
ffplay INPUT -af lowpass=3000,highpass=200
I'm sure that vlc can do the same.
Offline
Do not recode these files. Most of the time, this is absolutely not an option.
Use metadata (tagging) - replaygain. Players know how to use them.
mpv --replaygain=track
Normalizing with ffmpeg gives the best results with the loudnorm filter.
https://ffmpeg.org/ffmpeg-filters.html#ebur128-1
For example.
mpv --af=lavfi=[loudnorm=I=-16:LRA=11:TP=-1.5] file.m4a
Best quality in two passes.
ffmpeg -i file.m4a -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=summary -f null /dev/null
Substitute the proposed data accordingly.
$II, $ILRA, $ITP, $IT, $TO
ffmpeg -i input.wav -af loudnorm=linear=true:I=-16:LRA=11:TP=-1.5:measured_I=$II:measured_LRA=$ILRA:measured_tp=$ITP:measured_thresh=$IT:offset=$TO:print_format=summary -ar 44100 out.wav
Only by playing with mpv.
mpv --af=lavfi=[loudnorm=linear=true:I=-16:LRA=11:tp=-2:measured_I=$II:measured_LRA=$ILRA:measured_tp=$ITP:measured_thresh=$IT:offset=$TO] file.m4a
Last edited by latalante1 (2021-09-28 15:29:00)
Offline