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

Cecil Westerhof Cecil at decebal.nl
Sat Jun 3 12:49:42 EEST 2023


Michael Koch <astroelectronic at t-online.de> writes:

> Am 02.06.2023 um 17:37 schrieb Cecil Westerhof via ffmpeg-user:
>>
>> This is abrupt. (It is better as nothing.) I would prefer it to slide
>> to for example 25% and a the end slide back to 100%. Something like:
>>      -                        -
>>       -                      -
>>        -                    -
>>         -                  -
>>          -                -
>>           ----------------
>
> I have added a simpler solution with "sendcmd" to chapter 3.5.
> http://www.astro-electronic.de/FFmpeg_Book.pdf

I did it with:
    inputfile=00096.MTS
    outputfile=00096.mkv
    start=31
    end=44
    ramp=1.5
    volume=0.05
    volumeCmd="
      '
        lerp(1, ${volume}, (t - ${start}) / (${ramp}))
        *
        between(t, ${start}, ${start} + ${ramp})

        +

        lerp(${volume}, 1, (t - ${end} + ${ramp}) / (${ramp}))
        *
        between(t, ${end} - ${ramp}, ${end})

        +

        ${volume}
        *
        bitand(gt(t, ${start} + ${ramp}), lt(t, ${end} - ${ramp}))
      '
      :enable='between(t, ${start}, ${end})'
      :eval=frame
    "

    ffmpeg -i ${inputfile}           \
           -vcodec copy              \
           -af "volume=${volumeCmd}" \
           -y ${outputfile}

The distortion by the wind was very loud, so the volume needed to be
set very low.

I think it is not necessary at the moment, but what if there are
several parts in the video where the audio has to be dimmed?


By the way: it is quit fast. :-D

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list