对于我的生活,我无法想出翻译:
-i foo.mp3 -filter_complex aformat=channel_layouts=mono,showwavespic=s=4000x1000 -frames:v 1 foo.png
进入fluent-ffmpeg命令。任何人都可以帮助我吗?
我尝试过最基本的命令:
var inputStream = fs.createReadStream('C:/Somewhere/foo.mp3')
var outputStream = fs.createWriteStream('C:/Somehere/foo.png')
var proc = ffmpeg()
.input(inputStream)
.complexFilter([
'showwavespic'
])
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
.save(outputStream);
我从处理程序中抛出了错误:an error happened: ffmpeg exited with code 1: Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_showwavespic_1
答案 0 :(得分:1)
您需要为将生成波形的complexFilter
指定一个输入,还需要设置一个我命名为waveform
的输出。
这是我的操作方式:(fluent-ffmpeg v2.1.2)
import FFMPEG from 'fluent-ffmpeg';
const ffmpeg = new FFMPEG({
source: 'path/to/input_file.mp3'
});
ffmpeg
.complexFilter(
[
`[0:a]aformat=channel_layouts=mono,compand=gain=-6,showwavespic=s=4000x1000:colors=#0025ff[waveform]`
],
['waveform']
)
.outputOptions(['-vframes 1'])
.on('start', () => {
console.log('FFMPEG started with command:', command);
})
.on('progress', () => {
console.log('progress:', progress);
})
.on('error', error => {
console.log('FFMPEG error:', error);
reject(error.message);
})
.on('end', () => {
console.log('FFMPEG is done!');
})
.saveToFile('path/to/output.png');
答案 1 :(得分:0)
该错误告诉您showwavespic
过滤器需要输入。
有关简单示例的示例:
var inputStream = fs.createReadStream('C:/Somewhere/foo.mp3')
var outputStream = fs.createWriteStream('C:/Somehere/foo.png')
var proc = ffmpeg()
.input(inputStream)
.complexFilter([
'[0:a]aformat=channel_layouts=mono,showwavespic=s=4000x1000'
])
.outputOptions(['-vframes 1'])
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
.save(outputStream);