brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -af volumedetect measures how loud a file is before you change it

Ffmpeg
~/tips/tip-ffmpeg-volumedetect

ffmpeg -i episode.mp3 -af volumedetect -f null - 2>&1 | grep -E 'mean_volume|max_volume'

Reports the average and peak volume of a file so you know how much to adjust it.

Before I make something louder, I want to know how much room there is. volumedetect measures the volume without writing a new file.

ffmpeg -i episode.mp3 -af volumedetect -f null - 2>&1 | grep -E 'mean_volume|max_volume'

-f null - throws the output away, so ffmpeg only reads and measures. The result comes out on stderr, which is why the 2>&1 is there before grep. You get two lines like these:

mean_volume: -21.1 dB
max_volume: -15.6 dB

The max volume is the useful one. 0 dB is the ceiling. Here the loudest peak sits at -15.6 dB, so you can raise everything by about 15 dB before anything clips:

ffmpeg -i episode.mp3 -af volume=15dB episode-louder.mp3

This is a plain gain change, the whole file goes up by the same amount. If one loud moment, a laugh or a door, already sits near 0 dB, the rest stays quiet and you’d need a compressor or the loudnorm filter instead. The mean also hides a lot: a quiet speaker with music in between gives an average that fits neither.

Further reading: FFmpeg filters documentation

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link