I’m trying to process an audio file (bg-music.mp3) using ffmpeg to achieve specific volume changes at certain time intervals and trim the file at 30 seconds. The requirements are:
- First 5 seconds at 100% volume
- Fade from 100% to 10% volume between 5 and 7 seconds
- From 25 to 27 seconds, fade audio to 100% volume and keep it until the end of the file
- Trim the file at 30 seconds
Here is the command I have used so far:
ffmpeg -i bg-music.mp3 -filter_complex "[0]volume=1:enable='between(t,0,5)',volume='if(between(t,5,7),1-(0.45*(t-5)),0.1)':enable='between(t,5,25)',volume='if(between(t,25,27),0.1+(0.45*(t-25)),1)':enable='gt(t,27)'" -t 30 output.mp3
While this command processes the file, the volume changes are not gradual between the specified intervals (5 to 7 seconds and 25 to 27 seconds). Instead, the volume changes abruptly rather than smoothly transitioning. Here’s the result
How can I correctly apply a gradual volume fade using ffmpeg to meet these requirements?