fluent-ffmpeg / node-fluent-ffmpeg

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

Error: Output stream closed when trying to stream an mp3 file with express #1135

Open ShaharBrandman opened 3 years ago

ShaharBrandman commented 3 years ago

Version information

Code to reproduce

const express = require('express')

const server = express()

const ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath('ffmpeg.exe')

server.get('/', (req, res) => {
    res.set('Content-Type', 'audio/mp3')

    ffmpeg()
        .input('track.mp3')
        .toFormat('mp3')
        .pipe(res, { end: true })
});

Expected results

track.mp3 to be streamed to the express server on root

Observed results

Error: Output stream closed
    at Timeout._onTimeout (C:\Users\Shahar_2\Desktop\Projects\CUNTMUSIC-Server\node_modules\fluent-ffmpeg\lib\processor.js:491:25)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
Emitted 'error' event on FfmpegCommand instance at:
    at emitEnd (C:\Users\Shahar_2\Desktop\Projects\CUNTMUSIC-Server\node_modules\fluent-ffmpeg\lib\processor.js:424:16)
    at Timeout._onTimeout (C:\Users\Shahar_2\Desktop\Projects\CUNTMUSIC-Server\node_modules\fluent-ffmpeg\lib\processor.js:491:17)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

Checklist

ricfio commented 3 months ago

The terminateTimeout option (PR https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/pull/1292) could solve this issue.