I'm trying to loop the audio to fit the size of the video. I use VIDEOSHOW to create VIDEO and videoshow uses fluent-ffmpeg. I already have this code on the command line that works perfectly:
`ffmpeg -y -r 1 -loop 1 -i image.png -stream_loop -1 -i audio.mp3 -c:a copy -r 1
-shortest -c:v libx264 -t 60 -vf scale=1280:720 video.mp4
but I don't know how to use it with node-fluent-ffmpeg, here's the code I use:
async function nodeFluentFfmpeg() {
let image = [image.png]
return new Promise((resolve, reject) => {
const videoOptions = {
fps: 30,
loop: segundoVideo, // seconds
transition: true,
transitionDuration: 1, // seconds
videoBitrate: 1024,
videoCodec: "libx264",
size: "1280x720",
audioBitrate: "128k",
audioChannels: 2,
format: "mp4",
pixelFormat: "yuv420p"
}
videoshow(image, videoOptions)
.audio("audio.mp3","**-stream_loop -1 -c:a copy -r 1**")// **ERROR IS HERE**
.save("video.mp4")
.on("start", function(command) {
console.log("Rendering : ", command);
})
.on("error", function(err, stdout, stderr) {
console.error("Error:", err);
console.error("ffmpeg stderr:", stderr);
})
.on("end", function(output) {
console.error("Video created in:", output);
resolve()
});
})
You can resolve with .inputOption(
-stream_loop -1);
.