fluent-ffmpeg/node-fluent-ffmpeg

vstack passthrough stream of buffered images

Closed this issue · 1 comments

I have an array of buffered images and i need a script to concat them on top of each other.

The current error I am getting is this
Invalid file index 1 in filtergraph description [0:v]scale=iw:ih[v0];[1:v]scale=iw:ih[v1];[2:v]scale=iw:ih[v2];[3:v]scale=iw:ih[v3];vstack=4

And I must say, it completely makes sense, because there is really just one input object - the PassThrough stream. But the stream contains the array of the inputs, am I right?

So how do I tell ffmpeg, that the rest of the inputs that its looking for is in the PassThhrough? Or is there any other way to vstack the buffered images?

I've already tried creating images from the buffered input images to make sure that they are not empty.

Version information

  • fluent-ffmpeg version: ^2.1.2
  • ffmpeg version: 6.0.1
  • OS: macOS 14.1.1, M1

Code to reproduce

return new Promise((resolve, reject) => {
        const posterOutputPath = `${outputPath}/output.jpg`;

        const inputStream = new PassThrough();
        buffers.forEach(buffer => { inputStream.write(buffer); });
        inputStream.end();

        let filter = '';
        buffers.forEach((buffer, index) => {
            filter += `[${index}:v]scale=iw:ih[v${index}];`;
        });
        filter += `vstack=${buffers.length}`;

        console.log(filter);

        ffmpeg(inputStream)
            .inputFormat('image2pipe')
            .complexFilter(filter)
            .outputOptions(['-frames:v 1', '-pix_fmt yuv420p'])
            .output(posterOutputPath)
            .on('end', () => {
                console.log('Images concatenated successfully');
                resolve(posterOutputPath);
            })
            .on('error', (err, stdout, stderr) => {
                console.error('Error concatenating images:', err);
                console.log("ffmpeg stdout:", stdout);
                console.log("ffmpeg stderr:", stderr);
                reject(err);
            })
            .run();
    }
ffmpeg stdout:
ffmpeg stderr: ffmpeg version 6.0-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, image2pipe, from 'pipe:0':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 2480x1080 [SAR 1:1 DAR 62:27], 25 fps, 25 tbr, 25 tbn
Invalid file index 1 in filtergraph description [0:v]scale=iw:ih[v0];[1:v]scale=iw:ih[v1];[2:v]scale=iw:ih[v2];[3:v]scale=iw:ih[v3];vstack=4.

Error: ffmpeg exited with code 1: Invalid file index 1 in filtergraph description [0:v]scale=iw:ih[v0];[1:v]scale=iw:ih[v1];[2:v]scale=iw:ih[v2];[3:v]scale=iw:ih[v3];vstack=4.

not necessary a issue, stackoverflow user taught me a workaround method