dgurkaynak / nodeshout Goto Github PK
View Code? Open in Web Editor NEWNative libshout bindings for node.js
License: MIT License
Native libshout bindings for node.js
License: MIT License
When a stream is finished
the html5 stream lose connection so I need to press Play again.
The weird part is that sometime it doesn't, so it's as if there is a variable delay between the start of the next stream. Which seem to stop the playback in the player.
I am using this
const fileStream = new FileReadStream('./some/music.mp3', 65536);
const shoutStream = fileStream.pipe(new ShoutStream(shout));
shoutStream.on('finish', () => {
// I start the next stream here
});
Is there a way to make sure the next stream is starting fast enough to not stop the connection?
I cloned the repo. when try to run this project it gives me
Error: Dynamic Linking Error: Win32 error 126
at new DynamicLibrary (C:\Users\anuj\Desktop\testing\nodeshout\node_modules\ffi-napi\lib\dynamic_library.js:75:11)
at Object.Library (C:\Users\anuj\Desktop\testing\nodeshout\node_modules\ffi-napi\lib\library.js:47:10)
at Object. (C:\Users\anuj\Desktop\testing\nodeshout\src\libshout.js:11:23)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object. (C:\Users\anuj\Desktop\testing\nodeshout\src\index.js:1:18)
Hi,
how to send Metadata to Icecast, please?
After streaming one mp3 file, the stream turns itself off. And when I try to play the second file, although the data is sent correctly, I cannot listen to it via icecast.
I am experimenting with this piece of code:
const nodeshout = require("nodeshout");
const fs = require("fs");
nodeshout.init();
// Create a shout instance
const shout = nodeshout.create();
// Configure it
shout.setHost('localhost');
shout.setPort(8000);
shout.setUser('source');
shout.setPassword('hackme');
shout.setMount('source');
shout.setFormat(1); // 0=ogg, 1=mp3
shout.setAudioInfo('bitrate', '320');
shout.setAudioInfo('samplerate', '44100');
shout.setAudioInfo('channels', '2');
console.log(shout.open());
function playFile(fileName, next) {
fs.open(fileName, 'r', function (status, fd) {
if (status) {
console.log(status.message);
return;
}
fs.fstat(fd, function (err, stats) {
var fileSize = stats.size,
bufferSize = fileSize,
chunkSize = 4096,
bytesRead = 0;
function read() {
var buffer = Buffer.alloc(bufferSize);
if ((bytesRead + chunkSize) > fileSize) {
chunkSize = (fileSize - bytesRead);
}
fs.read(fd, buffer, 0, chunkSize, bytesRead, function (err, bytesRead_, buffer) {
if (err) {
console.log(e);
return;
}
bytesRead += bytesRead_;
console.log(fileName, 'Bytes read:' + bytesRead + ' Total:' + fileSize);
if (bytesRead_ > 0) {
console.log(shout.send(buffer, bytesRead_));
setTimeout(read, Math.abs(shout.delay()));
} else {
console.log('Zero bytes read, aborting');
fs.closeSync(fd);
setTimeout(next, Math.abs(shout.delay()));
}
});
}
read();
});
});
}
const fileNames = fs.readdirSync("./test-mp3s");
let idx = -1;
function playNext() {
let n = fileNames[(idx = ((idx + 1) % fileNames.length))];
console.log(n);
playFile(`./test-mp3s/${n}`, () => {
playNext();
});
}
playNext();
Hi,
let's say we have a DJ Mix of multiple songs wich is one long audio file.
Is there a way to determine the current position of the stream so that we can inject the correct metadata ?
mp3 is fine. But I can't play ogg files.
var song = './mysong.ogg';
shout.setFormat(0); // 0=ogg, 1=mp3
"Read 65536 bytes of data" messages flow too fast, then stream stops, listeners can't hear anything.
I am having trouble connecting connecting nodeshout to external Icecast servers. When connecting to localhost, it works perfectly; but if I put in the hostname for an Icecast server on another computer, the stream fails to start.
The program stops when shout.open()
invokes ffi_call()
in the FFI proxy
function. There is no console output, it just hangs.
Here's my stack trace:
Trace
at eval (eval at proxy (./node_modules/ffi/lib/_foreign_function.js:59:5), <anonymous>:1:9)
at Object.proxy [as shout_open] (./node_modules/ffi/lib/_foreign_function.js:59:5)
at shoutT.open (./node_modules/nodeshout/src/shoutT.js:185:21)
at Object.<anonymous> (./index.js:76:7)
at Module._compile (internal/modules/cjs/loader.js:686:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
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?
Is there a way to get notified when you get disconnected from the icecast server?
Error: ENOENT: no such file or directory, open 'libshout.so'
Some enviroment info:
Node version: 10.19.0
NPM version: 6.13.4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.