[FFmpeg-user] Replacing First 90 Seconds of a Video with Silence or with Another Audio Clip

Ryan Williams rwilliams at busivid.com
Tue Jan 19 04:02:02 CET 2016


On Tuesday, 19 January 2016 02:13 Sam Logan <shapableline at gmail.com> wrote:

> I have a video AVI file, "Video.avi", consisting of a video and an 
> audio track, and a separate audio file, "Audio.mp3". I want to do the 
> following two things:
>
> (1)
>
> First, I want to produce a version of the video, "OutputSilenced.avi", 
> which would be identical to the original video except that the first 
> 90 seconds of the video's audio are replaced with silence (to clarify, 
> I want to REPLACE, as in overwrite, the first 90 seconds, NOT insert 
> 90 seconds of silence to push the audio back 90 seconds).
>

-af "volume=enable='lte(t,90)':volume=0"

http://ffmpeg.org/ffmpeg-filters.html#volume
http://ffmpeg.org/ffmpeg-filters.html#Timeline-editing

> (2)
>
> Second, I want to produce a version of the video, 
> "OutputReplaced.avi", which would be identical to the original video 
> except that the first 90 seconds of the video's audio are replaced 
> with the first 90 seconds of "Audio.mp3" (again, to be clear, I want 
> to REPLACE, as in overwrite, the first 90 seconds, NOT insert 90 
> seconds of audio to push the original audio back 90 seconds).
>
> How commands would I use to do this with FFmpeg? Ideally, I would like 
> to just remux without doing any re-encoding. Thanks in advance.

Only way I can think of is to use a combination of the volume filter above to suppress the audio form the video and chain it with 'amix' to create a new audio track.

If you run into volume level problems using 'amix' try a combination of 'amerge' to make it a 4 channel track then 'pan' to change it back into stereo.

http://ffmpeg.org/ffmpeg-filters.html#amix
http://ffmpeg.org/ffmpeg-filters.html#amerge-1
http://ffmpeg.org/ffmpeg-filters.html#pan




More information about the ffmpeg-user mailing list