Open ShevKG opened 2 years ago
Try adding the .format('mp4') for example.
I don't want to just say “same issue!”, so below is code for a similar situation. ffmpeg
successfully converts the file, and I can verify the audio is as expected if I write to file and listen to it. However, the PassThrough
stream doesn't seem to ever get ran, none of the console.log
statements fire.
Something to note: the events progress
and end
never fire either. stderr
is the only one that gets triggered, although weirdly it prints out all messages from ffmpeg
, not just stderr
. That piece of output is consistent with running ffmpeg
in the command line without fluent-ffmpeg
.
It's sad that we can't make conversion work with buffers and/or streams. That would open up the possibility of in-memory file conversion, which is what I'm aiming for. I don't mind writing to disk, but it'd be cooler to do this The Node Way 😄
const buffers = []
const bufferStream = new stream.PassThrough()
bufferStream
.on('start', () => {
console.log('Pass-through stream has started')
})
.on('data', function (buf) {
console.log('bufferStream data', buf)
buffers.push(buf)
})
.on('end', function () {
const outputBuffer = Buffer.concat(buffers)
console.log('Done preparing bufferStream')
})
ffmpeg(inputBuffer)
.audioCodec('libvorbis')
.format('ogg')
.on('start', (commandLine) => {
console.log('ffmpeg started conversion', commandLine)
})
.on('stderr', function (stderrLine) {
console.error('Stderr output: ' + stderrLine)
})
.on('error', function (err) {
console.error('ffmpeg-error', err)
reject(err)
})
.on('progress', function (progress) {
console.log('ffmpeg-output', Math.round(progress.percent))
})
.on('end', function () {
console.log('Formating finished!')
})
.writeToStream(bufferStream)
Finding this too - is it not possible to merge and stream the output to buffers? I don't want to save to file - just do it in memory
Hello, i am trying to get buffer after ffmpeg convert my audio contained in a writable buffer which i gave to ffmpeg constructor. Is it possible to do that without third-party modules?
Code to reproduce
Expected results
Observed results
p.s I am sorry for incorrect example. I just want to show what i want to achieve