fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

`pipeline` utility does not work with all commands #1147

Open asaphaaning opened 3 years ago

asaphaaning commented 3 years ago

Version information

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