Fluent-ffmpeg from an array of input files

I want to use fluent-ffmpeg to create videos from the last n directory images or database entries.

What is the correct syntax?

These are my attempts:

Mimic shell team

 ffmpeg() .addInput('ls *png | tail -n 17') .inputOptions("-pattern_type glob") .output("output.mp4").run() 

but it does not accept shell commands;

space separated paths

 ffmpeg() .addInput('a*.png b*.png ') .inputOptions("-pattern_type glob") .output("output.mp4").run() 

but it does not accept a list of files separated by spaces;

Array of image paths

 ffmpeg() .addInput(array) // ['aa.png', 'a1.png',,,'bbb.png'] .inputOptions("-pattern_type glob") .output("output.mp4").run() 

but it does not accept arrays.

EDIT:

Also, from Merge multiple videos using node fluent ffmpeg , I can add multiple inputs using an array of files, like

 var ffmpeg= require('fluent-ffmpeg'); var f=ffmpeg() pngarr.forEach(p => f.input(p)) /// pngarr is my array of png paths 

But the launch

 f.output("./output.mp4").run() 

I only get videos from 0 seconds containing the first png list.

+6
source share
1 answer

Ffmpeg methods are chained, so you can use a reducer like this:

 var chainedInputs = inputlist.reduce((result, inputItem) => result.addInput(inputItem), ffmpeg()); 

The last edit almost did the same, but it continues to call .input () at the same level, not over the previous

+3
source

Source: https://habr.com/ru/post/1013165/


All Articles