For the life of me I cannot figure out to translate:
-i foo.mp3 -filter_complex aformat=channel_layouts=mono,showwavespic=s=4000x1000 -frames:v 1 foo.png
Into a fluent-ffmpeg command. Can anyone help me out?
I have tried with the most basic command:
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);
I get the error thrown from the handler: an error happened: ffmpeg exited with code 1: Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_showwavespic_1
You need to specify an input for the complexFilter
that will be taken for generating the waveform, as well as, you need to set an output which I named waveform
.
This is how I do it: (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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With