[FFmpeg-user] Dim audio in parts where there is a lot of wind

MacFH - C E Macfarlane - News news at macfh.co.uk
Fri Jun 2 20:05:05 EEST 2023


On 02/06/2023 07:39, Cecil Westerhof via ffmpeg-user wrote:
> German Geraskin <german.geraskin at gmail.com> writes:
> 
>>> I have videos where the audio is mostly reasonable good, but sometimes
>>> the wind creates havoc. Is there a way to dial the volume a good deal
>>> down for those parts only?
>>> It would be even better if that could be down in say half a second
>>> instead of at once.
>>
>> Hi, Cecil
>>
>> You can use the volume audio filter.
>> Example for Linux version of ffmpeg:
>>
>>    -af volume=0.5:enable='between(t\,26.12\,28.64)'
>>
>> It means - set volume to 0.5 between 26.12 and 28.64 seconds.
> 
> Thanks, I will try it out. I can do this several times?
> This is abrupt, there is no possibility to do it smooth?

You can combine it with fades.  For example the following will fade out 
over 2s, mute for 2s, fade in for 2s:

-af 
"afade=t=out:st=0:d=2,volume=enable='between(t,2,4)':volume=0,afade=t=in:st=4:d=2"

Notes:

I don't know if it's possible to fade to or from a given level other 
than zero, but perhaps, given the above as a starting point, someone 
else can help further with that.

Using the fade and volume filters re-encodes the audio, which may be a 
problem if, as is usual, lossy rather than lossless encodings are being 
used.  You can simply alter the bit rate back to its original level, for 
example ...
	-b:a 320k
... but with lossy encodings repeated re-encoding reduces quality 
somewhat with each iteration, so is something to be avoided.  To avoid 
this, you can separate the soundtrack into chunks such as ...

0:00-0:02	Temp1.* - Fade in, so re-encoded
0:02-5:00	Temp2.* - Good, original sound
5:00-5:02	Temp3.* - Fade out, so re-encoded

... then concatenate these chunks together using the concatenate filter:

	-f concat -i ..\concat.txt


More information about the ffmpeg-user mailing list