You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-26 22:13:53 +01:00
playaround with settings
This commit is contained in:
@@ -21,12 +21,9 @@ checkFFmpeg().then((ffmpegPath) => {
|
|||||||
logInfo(`${consoleLogTitle} Using ${ffmpegPath === 'ffmpeg' ? 'system-installed FFmpeg' : 'ffmpeg-static'}`);
|
logInfo(`${consoleLogTitle} Using ${ffmpegPath === 'ffmpeg' ? 'system-installed FFmpeg' : 'ffmpeg-static'}`);
|
||||||
logInfo(`${consoleLogTitle} Starting audio stream on device: \x1b[35m${serverConfig.audio.audioDevice}\x1b[0m`);
|
logInfo(`${consoleLogTitle} Starting audio stream on device: \x1b[35m${serverConfig.audio.audioDevice}\x1b[0m`);
|
||||||
|
|
||||||
const sampleRate =
|
const sampleRate = Number(this?.Server?.SampleRate || serverConfig.audio.sampleRate || 44100) + Number(serverConfig.audio.samplerateOffset || 0);
|
||||||
Number(this?.Server?.SampleRate || serverConfig.audio.sampleRate || 44100) +
|
|
||||||
Number(serverConfig.audio.samplerateOffset || 0);
|
|
||||||
|
|
||||||
const channels =
|
const channels = Number(this?.Server?.Channels || serverConfig.audio.audioChannels || 2);
|
||||||
Number(this?.Server?.Channels || serverConfig.audio.audioChannels || 2);
|
|
||||||
|
|
||||||
let ffmpeg = null;
|
let ffmpeg = null;
|
||||||
let restartTimer = null;
|
let restartTimer = null;
|
||||||
@@ -39,16 +36,12 @@ checkFFmpeg().then((ffmpegPath) => {
|
|||||||
|
|
||||||
let inputArgs;
|
let inputArgs;
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') inputArgs = ["-f", "dshow", "-i", `audio=${device}`];
|
||||||
inputArgs = ["-f", "dshow", "-i", `audio=${device}`];
|
else if (process.platform === 'darwin') inputArgs = ["-f", "avfoundation", "-i", device || ":0"];
|
||||||
} else if (process.platform === 'darwin') {
|
else inputArgs = ["-f", "alsa", "-i", device];
|
||||||
inputArgs = ["-f", "avfoundation", "-i", device || ":0"];
|
|
||||||
} else {
|
|
||||||
inputArgs = ["-f", "alsa", "-i", device];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"-fflags", "+nobuffer",
|
"-fflags", "+flush_packets",
|
||||||
"-flags", "low_delay",
|
"-flags", "low_delay",
|
||||||
"-rtbufsize", "4096",
|
"-rtbufsize", "4096",
|
||||||
"-probesize", "128",
|
"-probesize", "128",
|
||||||
@@ -79,15 +72,11 @@ checkFFmpeg().then((ffmpegPath) => {
|
|||||||
|
|
||||||
logDebug(`${consoleLogTitle} Launching FFmpeg with args: ${args.join(' ')}`);
|
logDebug(`${consoleLogTitle} Launching FFmpeg with args: ${args.join(' ')}`);
|
||||||
|
|
||||||
ffmpeg = spawn(ffmpegPath, args, {
|
ffmpeg = spawn(ffmpegPath, args, {stdio: ['ignore', 'pipe', 'pipe']});
|
||||||
stdio: ['ignore', 'pipe', 'pipe']
|
|
||||||
});
|
|
||||||
|
|
||||||
ffmpeg.stdout.pipe(audio_pipe, { end: false });
|
ffmpeg.stdout.pipe(audio_pipe, { end: false });
|
||||||
|
|
||||||
connectMessage(
|
connectMessage(`${consoleLogTitle} Connected FFmpeg → MP3 → audioWss`);
|
||||||
`${consoleLogTitle} Connected FFmpeg → MP3 → Server.StdIn`
|
|
||||||
);
|
|
||||||
|
|
||||||
ffmpeg.stderr.on('data', (data) => {
|
ffmpeg.stderr.on('data', (data) => {
|
||||||
const msg = data.toString();
|
const msg = data.toString();
|
||||||
@@ -97,10 +86,7 @@ checkFFmpeg().then((ffmpegPath) => {
|
|||||||
const match = msg.match(/time=(\d\d):(\d\d):(\d\d\.\d+)/);
|
const match = msg.match(/time=(\d\d):(\d\d):(\d\d\.\d+)/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const [_, hh, mm, ss] = match;
|
const [_, hh, mm, ss] = match;
|
||||||
const totalSec =
|
const totalSec = parseInt(hh) * 3600 + parseInt(mm) * 60 + parseFloat(ss);
|
||||||
parseInt(hh) * 3600 +
|
|
||||||
parseInt(mm) * 60 +
|
|
||||||
parseFloat(ss);
|
|
||||||
|
|
||||||
if (lastTimestamp !== null && totalSec === lastTimestamp) {
|
if (lastTimestamp !== null && totalSec === lastTimestamp) {
|
||||||
staleCount++;
|
staleCount++;
|
||||||
@@ -129,11 +115,8 @@ checkFFmpeg().then((ffmpegPath) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ffmpeg.on('exit', (code, signal) => {
|
ffmpeg.on('exit', (code, signal) => {
|
||||||
if (signal) {
|
if (signal) logWarn(`${consoleLogTitle} FFmpeg killed with signal ${signal}`);
|
||||||
logWarn(`${consoleLogTitle} FFmpeg killed with signal ${signal}`);
|
else if (code !== 0) logWarn(`${consoleLogTitle} FFmpeg exited with code ${code}`);
|
||||||
} else if (code !== 0) {
|
|
||||||
logWarn(`${consoleLogTitle} FFmpeg exited with code ${code}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
logWarn(`${consoleLogTitle} Restarting FFmpeg in 5 seconds...`);
|
logWarn(`${consoleLogTitle} Restarting FFmpeg in 5 seconds...`);
|
||||||
setTimeout(launchFFmpeg, 5000);
|
setTimeout(launchFFmpeg, 5000);
|
||||||
|
|||||||
Reference in New Issue
Block a user