I
I
ilenom2018-11-25 18:07:09
Video
ilenom, 2018-11-25 18:07:09

How to add audio to video with ffmpeg?

Good afternoon!
Friends, we need your help!
There is a video in mp4 format with an audio track, you need to overlay another audio on this video.
How can this be done with ffmpeg?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-11-25
@sergiks

Upd. to mix the original audio from a video file with a separate audio track, and of a shorter length than the video, you will firstly have to repeat the overlay audio file, and secondly, use the amix audio filter :

ffmpeg \
-i video.mp4 \
-filter_complex "amovie=audio.mp3:loop=0,asetpts=N/SR/TB[over]; [0][over]amix=duration=shortest" \
-c:v copy \
result.mp4

Old answer, about replacing the audio track.
To replace the original audio with another one from a separate file, you need to specify both inputs, and use -map to show where to get audio and video from.
More or less like this:
ffmpeg \
-i video.mp4 \
-i newAudio.mp3 \
-c:v copy \
-c:a aac \
-map 0:v:0 \
-map 1:a:0 \
result.mp4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question