此命令适用于ffmpeg fluent
我想循环遍历一个数组而不是将结果作为可链接命令的一部分附加,但我在下面的尝试似乎不起作用。还有另一种方式吗?
let streamYT = (YTrtmp) => {
let output = ''
for (var i in YTrtmp) {
output = output + ".output('rtmp://a.rtmp.youtube.com/live2/" + YTrtmp[i] + "') "
}
console.log(output)
console.log("streaming to youtube")
var proc3 = new ffmpeg({ source: inputURL, timeout: 0 })
.addOption('-vcodec', 'libx264')
.addOption('-acodec', 'aac')
.addOption('-crf', 26)
.addOption('-aspect', '640:360')
.addOption('-f', 'flv')
.withSize('640x360')
.on('start', function(commandLine) {
console.log('Query : ' + commandLine);
})
.on('error', function(err) {
console.log('Error: ' + err.message);
})
.output('./public/videos/output/' + outputName + '.mp4', function(stdout, stderr) {
console.log('Convert complete' +stdout)
})
.output
.run()
}
输出的错误如下
TypeError: (intermediate value).addOption(...).addOption(...).addOption(...).addOption(...).addOption(...).withSize(...).on(...).on(...).output(...).output.run is not a function
答案 0 :(得分:0)
而不是尝试执行字符串output
,看起来你应该将输出命令链接到最后,如下所示:
let streamYT = (YTrtmp) => {
var proc3 = new ffmpeg({ source: inputURL, timeout: 0 })
.addOption('-vcodec', 'libx264')
.addOption('-acodec', 'aac')
.addOption('-crf', 26)
.addOption('-aspect', '640:360')
.addOption('-f', 'flv')
.withSize('640x360')
.on('start', function(commandLine) {
console.log('Query : ' + commandLine);
})
.on('error', function(err) {
console.log('Error: ' + err.message);
})
.output('./public/videos/output/' + outputName + '.mp4', function(stdout, stderr) {
console.log('Convert complete' +stdout)
});
for (var i in YTrtmp) {
proc3 = proc3.output('rtmp://a.rtmp.youtube.com/live2/" + YTrtmp[i] + "')
}
console.log("streaming to youtube")
proc3.run()
}