Adjust Audio Volume in FFmpeg Using Scale Factor
This article provides a quick and practical guide on how to use the
volume filter in FFmpeg to adjust audio levels using a
scale factor. You will learn the basic command syntax, how to use
multipliers to increase or decrease volume, and how to apply these
changes to both audio-only files and video files without altering the
video stream.
To adjust the audio volume in FFmpeg using a scale factor, you need
to use the audio filter option, represented by -filter:a or
the shorthand -af. The scale factor is a multiplier where
1.0 represents the original volume, numbers lower than
1.0 decrease the volume, and numbers higher than
1.0 increase it.
Basic Syntax
The basic syntax for applying a volume scale factor is:
ffmpeg -i input.mp3 -filter:a "volume=factor" output.mp3Decreasing Volume
To decrease the volume, use a decimal value between 0.0
and 1.0. For example, to reduce the volume to 50% (half) of
its original level, use a scale factor of 0.5:
ffmpeg -i input.wav -af "volume=0.5" output.wavIncreasing Volume
To increase the volume, use a value greater than 1.0.
For example, to double the volume (200% of the original level), use a
scale factor of 2.0:
ffmpeg -i input.mp3 -af "volume=2.0" output.mp3Adjusting Audio Volume in a Video File
When adjusting the audio of a video file, you should copy the video
stream directly without re-encoding it to save time and preserve video
quality. Use the -c:v copy option to achieve this:
ffmpeg -i input.mp4 -af "volume=1.5" -c:v copy output.mp4In this command, the audio volume is increased by 1.5 times, while the video stream is copied directly to the new file.