dgurkaynak / nodeshout

Native libshout bindings for node.js
MIT License
49 stars 19 forks source link

Stream randomly ends after 8-9 minutes #12

Closed BleedFeed closed 1 year ago

BleedFeed commented 1 year ago

i use a ffmpeg readableStream as input

  const ffmpegProcess = spawn('ffmpeg',[
        '-i','pipe:3',
        '-f','mp3',
        '-ar','44100',
        '-ac','2',
        '-codec:a','libmp3lame',
        '-b:a','128k',
        'pipe:4'],{stdio:['ignore','ignore','ignore','pipe','pipe']});
        ytdlStream.pipe(ffmpegProcess.stdio[3]);
        resolve(ffmpegProcess.stdio[4]);

below code works for hours without any issue

    readable.on('data',async (chunk)=>{
        shout.sync();
        shout.send(chunk,chunk.length);
    });

but it's blocking so i've tried making it non-blocking like this

    readable.on('data',async (chunk)=>{
        readable.pause();
        shout.send(chunk,chunk.length);
        const delay = shout.delay();
        await new Promise((resolve)=>setTimeout(resolve,delay));
        readable.resume();
    });

this works until 8-9 minutes after that for some reason the stream ends and mountpoint gets destroyed. Is there a better way to read from a stream?

BleedFeed commented 1 year ago

The problem was in the ffmpeg stream

dgurkaynak commented 1 year ago

Hey @BleedFeed, sorry for the late response. But I guess you have already solved the problem?