I am trying to combine a static image & an audio into a video. I want the video to be as long as the audio file. I am using ffmpeg and am executing it via nodejs:
var args = [
"-loop",
"1",
"-i",
pathToImage,
"-i",
pathToAudio,
"-c:v",
"libx264",
"-tune",
"stillimage",
"-b:a",
"96k",
"-c:a",
"aac",
"-pix_fmt",
"yuv420p",
"-f",
"mp4",
"-shortest",
destinationPath,
]
var cmd = "ffmpeg"
var proc = spawn(cmd, args)
So the ffmpeg command that's executed should be this:
-loop 1 -i pathToImage.png -i pathToAudio.mp3 -c:v libx264 -tune stillimage -b:a 96k -c:a aac -pix_fmt yuv420p -f mp4 -shortest destinationPath.mp4
However, this creates a video which is quite a few seconds longer than my audio file, and I do not understand why that is or how to fix it? I have to admit I do not understand all the parameters 100%, so I am wondering if someone could maybe help me out here.