Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Output stream closed when stream passed to aws s3 #1199

@EivydasV

Description

@EivydasV

Version information

  • fluent-ffmpeg version: 2.1.2
  • ffmpeg version: The lastest
  • OS: Linux

Code to reproduce

import { Upload } from '@aws-sdk/lib-storage';
import { PassThrough } from 'node:stream';
import ffmpeg from 'fluent-ffmpeg';

    const format = 'webm';
    const command = ffmpeg()
      .input(fs.createReadStream(data.filePath))
      .format(format)
      .outputOptions([
        '-vf scale=1280x720',
        '-b:v 1024k',
        '-minrate 512k',
        '-maxrate 1485k',
        '-tile-columns 2',
        '-g 240',
        '-threads 8',
        '-quality good',
        '-crf 32',
        '-c:v libvpx-vp9',
        '-c:a libopus',
        '-speed 4',
      ])
      .pipe()
      .on('progress', (progress) => {
        console.log(progress);
      })
      .on('end', function () {
        console.log('Video conversion complete');
      })
      .on('error', function (err) {
        console.log('An error occurred: ' + err.message);
      });

    const folder = path.join(AwsFolder.VIDEOS, data.userId, data.videoId);
    const fileName = `${nanoid()}_${data.scale}.${format}`;
    const fullPath = path.join(folder, fileName);
    const upload = new Upload({
      client: this.s3BucketService.client,
      params: {
        Bucket: 'youtube-nest',
        Key: fullPath,
        Body: command as PassThrough,
      },
    });

    await upload.done();

When I run this I am getting Error: Output stream closed(from fluent-ffmpeg), error occurs after end event is emitted. Looks like that Passthrough closes stream before is finished (I am using @aws-sdk/client-s3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions