`pipeline` utility does not work with all commands
Author: asaphaaningCreated Sep 9, 2021Updated Feb 21, 2025
Version information
- fluent-ffmpeg version: 2.1.18
- ffmpeg version: 4.4
- OS: Linux arm64 (Manjaro)
Code to reproduce
This does NOT work
async function* test(stream) {
for await (const chunk of stream) {
console.log(chunk)
yield chunk
}
}
const pt = new PassThrough()
ffmpeg(SOURCE)
.outputFPS(FPS)
.size(`${WIDTH}x${HEIGHT}`)
.videoCodec('ppm')
.withNoAudio()
.outputFormat('image2pipe')
.stream(pt, { end: true })
pipeline(
pt,
test,
err => console.log(err)
)
This DOES work
const pt = new PassThrough()
ffmpeg(SOURCE)
.outputFPS(FPS)
.size(`${WIDTH}x${HEIGHT}`)
.videoCodec('ppm')
.withNoAudio()
.outputFormat('image2pipe')
.stream(pt, { end: true })
pt.pipe(new Transform({transform(chunk, encoding, callback) {
console.log(chunk); callback();
}}))
Expected results
Should remain piped to child process. Even with backpressure applied. Instead, the stream ends abruptly after a second or two.
Observed results
Does not unless the chain is constructed using pipe
pipeline does seem to work fine with PCM transcoding so I'm not sure what the problem is exactly.
Checklist
- I have read the FAQ
- I tried the same with command line ffmpeg and it works correctly (hint: if the problem also happens this way, this is an ffmpeg problem and you're not reporting it to the right place)
- I have included full stderr/stdout output from ffmpeg
Source: fluent-ffmpeg/node-fluent-ffmpeg