1

I am trying to run the my ffmpeg command to merge an audio file with a video that has sound. The command I am using lowers down the volume on the audio file, since it is music and the video has audio.

Im having a problem with the audio file being cut off when the video's sound ends, instead of continuing until the video finishes.

/usr/local/bin/ffmpeg \
-i thepath/input.mp4 \
-i musicpath/music.mp3 \
-filter_complex \
"[1:a]volume=-21dB,apad[A]; \
[0:a][A]amerge[out]" \
-c:v libx264 -c:a aac -map 0:v -map "[out]" \
-preset ultrafast -threads 0 -profile:v baseline \
-ac 2 -pix_fmt yuv420p -t 30 -y thepath/output.mp4 2>&1

Im confused as to why it doesnt work as intended?

1 Answer 1

1

amerge terminates with the shortest input stream, which here is the video's audio, and which doesn't span upto the video stream's end.

Add apad to the video's audio as well and add -shortest as an output option.

Full command would be

/usr/local/bin/ffmpeg \
-i thepath/input.mp4 \
-i musicpath/music.mp3 \
-filter_complex \
"[0:a]apad[main]; \
 [1:a]volume=-21dB,apad[A]; \
[main][A]amerge[out]" \
-c:v libx264 -c:a aac -map 0:v -map "[out]" \
-preset ultrafast -threads 0 -profile:v baseline \
-ac 2 -pix_fmt yuv420p -t 30 -shortest -y thepath/output.mp4 2>&1
2
  • how do i add the apad to the videos audio?
    – 730wavy
    Commented Dec 21, 2018 at 17:48
  • 1
    Example added..
    – Gyan
    Commented Dec 21, 2018 at 17:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .