I have two file, video.mp4 and audiotrack.mp3. I am using the following command to insert the audio with the video to create an audio track in the video, and it's working.

ffmpeg -y -i video.mp4 -i audiotrack.mp3 -af apad -map 0:v -map 1:a -c:v copy -shortest finalwithAudio.mp4

The problem: The audio works fine but ends aburptly when the video reaches its end. I want it to start fading out 1 or 2 seconds before the video end. is it possible?


Use the afade filter. Assuming video.mp4 is 10 seconds long and a fade of 1 second is wanted:

ffmpeg -i video.mp4 -i audio.mp3 -af "apad,afade=type=out:start_time=9:duration=1" -c:v copy -shortest output.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.