1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 06:23:53 +01:00

UI changes, accessibility features, ffmpeg adjustments

This commit is contained in:
NoobishSVK
2024-01-31 21:28:25 +01:00
parent 525ae519d7
commit 68e60223a3
18 changed files with 1056 additions and 228 deletions

View File

@@ -3,13 +3,20 @@ const config = require('../userconfig.js');
const consoleCmd = require('../console.js');
function enableAudioStream() {
var ffmpegCommand;
// Specify the command and its arguments
const command = 'ffmpeg';
const flags = '-fflags +nobuffer+flush_packets -flags low_delay -rtbufsize 6192 -probesize 64 -audio_buffer_size 20';
const codec = '-acodec pcm_s16le -ar 48000 -ac 1';
const flags = '-fflags +nobuffer+flush_packets -flags low_delay -rtbufsize 6192 -probesize 64';
const codec = '-acodec pcm_s16le -ar 48000 -ac 2';
const output = '-f s16le -fflags +nobuffer+flush_packets -packetsize 384 -flush_packets 1 -bufsize 960';
// Combine all the settings for the ffmpeg command
const ffmpegCommand = `${flags} -f dshow -i audio="${config.audioDeviceName}" ${codec} ${output} pipe:1 | node stream/3las.server.js -port ${config.audioPort} -samplerate 48000 -channels 1`;
if (process.platform === 'win32') {
// Windows
ffmpegCommand = `${flags} -f dshow -i audio="${config.audioDeviceName}" ${codec} ${output} pipe:1 | node stream/3las.server.js -port ${config.audioPort} -samplerate 44100 -channels 2`;
} else {
// Linux
ffmpegCommand = `${flags} -f alsa -i "${config.audioDeviceName}" ${codec} ${output} pipe:1 | node stream/3las.server.js -port ${config.audioPort} -samplerate 48000 -channels 2`;
}
consoleCmd.logInfo("Launching audio stream on port " + config.audioPort + ".");
// Spawn the child process
@@ -17,24 +24,24 @@ function enableAudioStream() {
if(config.audioDeviceName.length > 2) {
const childProcess = spawn(command, [ffmpegCommand], { shell: true });
// Handle the output of the child process (optional)
/*childProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
// Handle the output of the child process (optional)
childProcess.stdout.on('data', (data) => {
consoleCmd.logDebug(`stdout: ${data}`);
});
childProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
childProcess.stderr.on('data', (data) => {
consoleCmd.logDebug(`stderr: ${data}`);
});
// Handle the child process exit event
childProcess.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
consoleCmd.logDebug(`Child process exited with code ${code}`);
});
// You can also listen for the 'error' event in case the process fails to start
childProcess.on('error', (err) => {
console.error(`Error starting child process: ${err}`);
});*/
consoleCmd.logError(`Error starting child process: ${err}`);
});
}
}