简体   繁体   English

来自输入文件数组的fluent-ffmpeg

[英]fluent-ffmpeg from an array of input files

I want to use fluent-ffmpeg to create a video of last n images of a directory, or database entries. 我想使用fluent-ffmpeg创建目录或数据库条目的后n个图像的视频。

Which is the correct syntax? 哪个是正确的语法?

These are my tries: 这些是我的尝试:

Mimic shell command 模拟shell命令

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

but it does not accept shell commands; 但是它不接受shell命令;

space - separated paths 空格分隔的路径

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

but it does not accept 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 am able to add multiple inputs using an array of files as 另外,从使用节点流利的ffmpeg合并多个视频 ,我能够使用文件数组添加多个输入为

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

But running 但是跑步

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

I obtain just a video of 0 seconds containing the first png of the list. 我只得到0秒的视频,其中包含列表的第一个png。

The ffmpeg methods are chainable, so you could use a reducer like so: ffmpeg方法是可链接的,因此您可以使用如下的reducer:

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

Your last edit nearly did the same thing, but it keeps calling .input() on the same level instead of on top of the previous 您的上一次编辑几乎做了同样的事情,但是它在同一级别而不是上一个级别继续调用.input()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM