Adjusting Audio Levels in Videos with ffmpeg: A Step-by-Step Guide
If you are experiencing an audio-video mismatch on Ubuntu 22.04 when using VLC media player, you can use the tools in VLC to adjust the audio synchronization. To do so, open VLC Player > Menu > Tools > Preferences > Advanced Preference. Click the Audio tab from the left list, make sure you have choose the All in the Show settings at the bottom-left corner. Check the settings of Audio desynchronization compensation and you can put a value in seconds to sync audio. Additionally, you can use the Equalizer feature in VLC to enhance and customize the sound of your digital music library. To do this, go to Window > Tools > Effects and Filters, click the check box next to the Enable option and select a preset, or adjust the frequency band sliders to adjust the sound manually.
If you want to further normalize the loudness of the file, you can use the loudnorm filter which implements the EBU R128 algorithm. To do this, run the command ffmpeg -i input.wav -filter:a loudnorm output.wav
. Automating the normalization processes with ffmpeg without having to do two passes is possible with the ffmpeg-normalize Python
program. This script defaults to EBU R128 normalization but peak and RMS normalization are also supported.
To change the sound volume, you can use FFmpeg's volume audio filter. If you want your volume to be half of the input volume, run the command ffmpeg -i input.wav -filter:a “volume=0.5” output.wav. To increase the volume by 10dB, run the command ffmpeg -i input.wav -filter:a “volume=10dB” output.wav. To reduce the volume, use a negative value.
Finally, to set or otherwise normalize the volume of a stream, peak and RMS normalization can be used. To normalize the volume to a given peak or RMS level, the file first has to be analyzed using the volumedetect filter. Read the output values from the command line log, then calculate the required offset, and use the volume filter as shown above.
You can use the ffmpeg tool to adjust the audio levels of a video. One way to do this is to use the volume filter, which allows you to increase or decrease the volume of the audio in a video. For example, to decrease the volume of the audio by 6 dB, you can use the following command:
ffmpeg -i input.mp4 -filter:a "volume=-6dB" output.mp4
You can also use other ffmpeg filter such as 'equalizer', 'compand' , 'pan' to adjust the audio level, balance and stereo. It's recommended to play with the filter option and see which one works best for your video.
ffmpeg -i input.mp4 -filter_complex "[0:a]equalizer=f=1000:t=h:width_type=h:w=1000[a0];[0:a]equalizer=f=1000:t=h:width_type=h:w=1000,compand=attacks=.01:decays=1:points=-90/-90|-40/-20|-20/-10|0/-3|20/3[a1];[a0][a1]pan=stereo|c0=c0|c1=c1" output.mp4
There are many other options and filters available in ffmpeg for adjusting audio levels and other aspects of the audio in a video. For example, you can use the 'amplify' filter to increase or decrease the volume of specific audio frequencies, or the 'compand' filter to adjust the dynamic range of the audio. Additionally, you can use the 'pan' filter to adjust the balance between left and right channels in stereo audio, or the 'equalizer' filter to adjust the levels of different frequency bands.
It's important to note that it's best to adjust audio levels on the separate audio track before merging it back with the video. That way you can have more control over the audio and make sure it's in the right level and quality.
Citations :
- https://help.ubuntu.com/stable/ubuntu-help/sound-volume.html.en
- https://filmora.wondershare.com/audio-editing/normalize-volume-vlc.html
- https://trac.ffmpeg.org/wiki/AudioVolume
- https://www.youtube.com/watch?v=15QyOPMZ9AM
- https://ottverse.com/transcode-audio-codec-ffmpeg-without-changing-video/
- https://www.vlchelp.com/syncing-audio-vlc-media-player/
- https://videoconverter.wondershare.com/sync-audio/vlc-audio-delay.html
- https://www.lifewire.com/improve-audio-quality-in-vlc-media-player-with-the-equalizer-2438322
- https://manpages.ubuntu.com/manpages/bionic/man1/ffmpeg-all.1.html