Hi. I'm trying to use node-ogg and node-vorbis in conjuction with icy to read an Icecast ogg stream (and redirect it somewhere else), but seems to have run into a problem - ogg decoder crashes.
Consider this code:
const logger = require('winston')
const Icecast = require('icy')
const Vorbis = require('vorbis')
// const Lame = require('lame')
const Speaker = require('speaker')
const OGG = require('ogg')
logger.level = 'debug'
global.logger = logger
var od = new OGG.Decoder()
var vd = new Vorbis.Decoder()
vd.on('format', format => {
logger.debug('vd', format)
})
vd.on('error',err => {
logger.debug('vd', err)
})
od.on('stream', stream => {
stream.pipe(vd)
})
od.on('error',err => {
logger.debug('od', err)
})
// **This code (same radio but using mp3 stream) works.**
/*
this._ice = Icecast.get('https://example.com:8001/radio.mp3', res => {
logger.info('Icecast info:', res.headers)
res.pipe(new Lame.Decoder()).pipe(new Speaker())
})
*/
this._ice = Icecast.get('https://example.com:8001/radio.ogg', res => {
logger.info('Icecast info:', res.headers)
res.pipe(od)//.pipe(new Speaker()) // this gives off 'Cannot pipe. Not readable' error
})
According to https://xiph.org/ogg/doc/libogg/ogg_stream_packetout.html this function returns -1 when, quote "if we are out of sync and there is a gap in the data. This is usually a recoverable error and subsequent calls to ogg_stream_packetout are likely to succeed.".
I replaced urls to radio for privacy's sake, it's a private radio.
Hi. I'm trying to use
node-ogg
andnode-vorbis
in conjuction withicy
to read an Icecast ogg stream (and redirect it somewhere else), but seems to have run into a problem - ogg decoder crashes.Consider this code:
when I run this code I get following output:
According to https://xiph.org/ogg/doc/libogg/ogg_stream_packetout.html this function returns -1 when, quote "if we are out of sync and there is a gap in the data. This is usually a recoverable error and subsequent calls to ogg_stream_packetout are likely to succeed.".
I replaced urls to radio for privacy's sake, it's a private radio.