[FFmpeg-user] Replacing a segment of audio

Paul B Mahol onemda at gmail.com
Mon Oct 22 16:29:22 EEST 2018


On 10/22/18, Steve Bick <sbicksubscript at comcast.net> wrote:
> I'm trying to replace just a segment of audio in an existing video with
> another piece of audio.
>
>
>
> Goal: I have a video w/ audio, and want to replace just the audio in a
> middle segment of the video without affecting the rest of the video and
> audio.
>
>
>
> The closest I've come is using this:
>
>
>
> -----
>
> ffmpeg.exe -y -i  "Video.mp4" -i "AudioToReplace.mp3" -filter_complex
> "[0:a]atrim=0:316,asetpts=PTS-STARTPTS[aud1];[1:a]atrim=0:172,asetpts=PTS-ST
> ARTPTS[aud2]"  -map 0:v -map "[aout]" -c:v copy -c:a libmp3lame New.mp4
>
> -----
>
>
>
> It results in the audio being replaced in the beginning of the video and the
> rest of the audio shifted.
>
>
>
> I'm having a difficult time understanding what the 'filter_complex' and
> 'map' parameters are doing but I think I'm getting close. Can someone please
> explain these and help me adjust my command above in order to achieve my
> goal?

Currently there is no easy way to do it. Best way is using trim &
concat filter/demuxer
on audio stream.


More information about the ffmpeg-user mailing list