I have a JSON file containing regions that I want to mute in a given audio file. How can I process the audio file to mute the file between the listed sections?
-
you could cut out the pieces and piece them back together...rogerdpack– rogerdpack2015-03-23 19:58:50 +00:00Commented Mar 23, 2015 at 19:58
-
I thought about that but it seems a very messy thing to do: as it requires chopping out the parts with audio I want in, then generating bits of silence, then concatenating, and hoping it doesn't end up with clicks where the merges are. Below solution works perfectly!kimadactyl– kimadactyl2015-03-24 12:28:15 +00:00Commented Mar 24, 2015 at 12:28
-
there is a "select" filter I wonder if it can work for audio...rogerdpack– rogerdpack2015-03-24 15:09:35 +00:00Commented Mar 24, 2015 at 15:09
2 Answers
The following command will mute two sections: between 5-10s and 15-20s:
ffmpeg -i video.mp4 -af "volume=enable='between(t,5,10)':volume=0, volume=enable='between(t,15,20)':volume=0" ...
Description:
-af is the audio filter. It works by specifying multiple volume filters that are enabled/disabled at the specified time. volume=enable='between(t,5,10)':volume=0 means use a volume filter that gets enabled between 5 and 10 seconds and sets the volume to 0.
7 Comments
-af is the audio filter. It works by specifying multiple volume filters that are enabled/disabled at the specified time. volume=enable='between(t,5,10)':volume=0 means use a volume filter that gets enabled between 5 and 10 seconds and sets the volume to 0.-vcodec copy to the command, it will make it so the video is not re-encoded (which is fine if you only need to edit the audio). e.g.: ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='between(t,5,10)':volume=0, volume=enable='between(t,15,20)':volume=0" out.mp4'between(t,26*60+40,26*60+42)'. It also supports floating point numbers (.e.g, 'between(t,26*60+40+0.5,26*60+42)' ).I came across this post because I was trying to see how to lower sections of audio in a video.
For example, I want the volume between 34 to 35 minutes, 37 to 40 minutes, 0.1 times of the input volume. Below works for me and hope it works for others who are after the same task:
C:\ffmpeg-4.4-full_build\bin>ffmpeg -i in_video.mp4 -filter:a "volume=enable='between(t,34*60,35*60)':volume=0.1, volume=enable='between(t,37*60,40*60)':volume=0.1" -vcodec copy out_video.mp4
Note the time in between needs to be seconds.
Refer to the link below for more info about the audio volume filter (-filter:a). https://trac.ffmpeg.org/wiki/AudioVolume