[FFmpeg-user] Replace part of the audio

Michael Koch astroelectronic at t-online.de
Sun Jan 22 19:50:20 EET 2023

Am 22.01.2023 um 16:56 schrieb Michael Koch:
> Am 22.01.2023 um 16:25 schrieb Paul B Mahol:
>> On 1/22/23, Michael Koch <astroelectronic at t-online.de> wrote:
>>> Am 21.01.2023 um 17:05 schrieb Paul B Mahol:
>>>> On 1/19/23, Michael Koch <astroelectronic at t-online.de> wrote:
>>>>> Am 19.01.2023 um 15:49 schrieb Alexander Bieliaev via ffmpeg-user:
>>>>>> How can I replace a part of the audio from and to a specific time 
>>>>>> with
>>>>>> some
>>>>>> other audio/sound (I want to replace it with beep in this case)?
>>>>> Here is an example:
>>>>> ffmpeg -lavfi sine=500:d=10 -y audio1.wav
>>>>> ffmpeg -lavfi sine=2000:d=10 -y audio2.wav
>>>>> ffmpeg -i audio1.wav -i audio2.wav -lavfi
>>>>> [0]volume='1-between(t,4,6)':eval=frame[a];[1]volume='between(t,4,6)':eval=frame[b];[a][b]amix 
>>>>> -y out.wav
>>>> That is never going to give smooth transitions.
>>>> Also overly complicated as can be simplified with commands to to amix
>>>> filter.
>>> If my example is too complicated, then please show a simpler example.
>> asendcmd=10.0 amix weights 'X Y',
>> X/Y being wanted volume of first/second input to amix filter.
> That doesn't work because the argument of asendcmd must be 
> encapsulated in quotes (because it contains spaces), and X Y must also 
> be encapsulated in quotes. Please show the whole command line.

This command line works with asendcmd and astreamselect:

ffmpeg -i audio1.wav -i audio2.wav -lavfi asendcmd="4 astreamselect map 
1",asendcmd="6 astreamselect map 0",astreamselect=map=0 -y out.wav

However with amix filter I have no idea what's the syntax for the string 
inside the string. It doesn't work.

ffmpeg -i audio1.wav -i audio2.wav -lavfi asendcmd="4 amix weights '0 
1'",amix=weights='1 0' -y out.wav


More information about the ffmpeg-user mailing list