fluent-ffmpeg / node-fluent-ffmpeg

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

Error: Output stream closed #1171

Closed iocmet closed 1 year ago

iocmet commented 2 years ago
  ffmpeg(ytdl('https://www.youtube.com/watch?v=' + req.query.id, {
    format: 'mp4'
  })).output(res)
  .noVideo()
  .format('mp3')
  .outputOptions('-ab','192k')
  .run();
Fan-55 commented 2 years ago

+1

iocmet commented 2 years ago

what

teresmitu commented 2 years ago

Any one solve this ?

Safricloud commented 1 year ago

Hello, hope this helps someone since I spent a lot of time debugging.

        ffmpeg({ stdoutLines: 0 })
            .input( readableStream ) 
            .inputFormat('g729')
            .audioCodec('pcm_s16le')
            .format('s16le')
            .stream()
            .on('error', (err) => {
                console.log('Error decoding G.729 payload:');
                console.log(err);
                callback(err);
            })
            .on('data', (chnk) => {
                // Append the chunk
                decodedAudio = Buffer.concat([decodedAudio, chnk]);
            })
            .on('end', () => {
                // Need to wait a bit here to allow the stream to finish correctly
                setTimeout(() => { callback(null, decodedAudio); }, 10);
            });

Before I added the setTimeout I was getting the "Output stream closed" error, and now its gone.

iocmet commented 1 year ago

Thanks, i currently not have this part of code in my app but i will close issue