ch1ller0 / fridgefm-radio-core

Simple lightweight package for creating your own radio station via NodeJS heavily inspired by Shoutcast and Icecast.
https://fridgefm.com
MIT License
44 stars 8 forks source link

Stream periodically stops at client after track ends #320

Open klen-list opened 2 years ago

klen-list commented 2 years ago

This happens randomly between different tracks. After reloading page stream continues. I see the same problem when using BASS: http://www.bass.radio42.com/help/html/322b7ddc-a9f5-21eb-c78a-f5937cd0d2f2.htm

Failed to decode media resource http://localhost:8000/stream. x27 [stream]
Failed to decode media resource http://localhost:8000/stream, error: Error Code: NS_ERROR_DOM_MEDIA_DECODE_ERR (0x806e0004)
Details: virtual mozilla::MediaResult __cdecl mozilla::FFmpegAudioDecoder<46465650>::DoDecode(mozilla::MediaRawData *, uint8_t *, int, bool *, mozilla::MediaDataDecoder::DecodedData &): FFmpeg audio error:-1094995529

Sometimes after page load the stream gives out the full length of the track instead of a per-second download: firefox_rizz3kMOgm And stops stream after finishing with the above error.

I even tried to export all the tracks to the same bitrate, but it didn't help.

const { PUBLIC_EVENTS, SHUFFLE_METHODS, Station } = require("@fridgefm/radio-core")
const http = require("http")

const station = new Station()
station.addFolder("./stream")

const reqListener = (req, res) => station.connectListener(req, res)
const radio = http.createServer(reqListener)

station.reorderPlaylist(SHUFFLE_METHODS.randomShuffle())

station.on(PUBLIC_EVENTS.NEXT_TRACK, async (track) => {
    const result = await track.getMetaAsync()
    console.log(result.title)
})

station.start()
radio.listen(8000)

It doesn't seem to be happening with your radio in the example. Maybe I'm setting something up wrong?

ch1ller0 commented 2 years ago

Hey, what are the contents of the stream folder? I assume there might be some issue considering synchronous folder walking

klen-list commented 2 years ago

stream folder just contains bunch of .mp3 files without any subfolders

ch1ller0 commented 2 years ago

Could you try to use another folder with just 2-3 mp3 files in it and see if the problem reproduces? And also, are there any helpful logs from the server/client? And also, which version are you using? I had similar issue but it was fixed in https://github.com/ch1ller0/fridgefm-radio-core/issues/34

LaganYT commented 1 year ago

this is happening to apple devices listening to my streams too.

ppalone commented 1 year ago

Wondering if this issue still exists, I'm too writing my own radio but in Go. I'm using ffmpeg for doing most of the heavy lifting like encoding, removing metadata (like idv3 tags etc). Occasionally, my client (<audio> tag) also disconnects while listening. It mostly occurs when the server is changing songs (like for example one song has ended and its trying to load the next song). @ch1ller0 did you encounter such issues after the idv3 removal fix? Let me know. Thanks.

ppalone commented 1 year ago

A hacky solution that I use is reconnect to stream when error occurs.

// audio -> audio element
audio.onerror = function (err) {
    console.error(err)

    audio.setAttribute('src', '/stream')
    audio.play().catch(console.error)
}
Sinkcat113 commented 2 days ago

I'm receiving this error and encountering the same issue.

(node:1066) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [Transform]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit (Usenode --trace-warnings ...to show where the warning was created) (node:1066) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added to [Transform]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit (node:1066) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [EventEmitter]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit

This is on the server. It's happened both on 3.2.6 and 3.2.7