fix most bugs, upgrade ffmpeg.

Need to fix logo in app, restart on settings change, and multicontrollers
This commit is contained in:
DevL0rd 2022-03-05 01:33:22 +07:00
parent b5f93d9c7d
commit 25f4cfd3bc
5 changed files with 16 additions and 18 deletions

View file

@ -92,9 +92,9 @@ function applyClientSettings() {
$("#ipInput").val(clientSettings.ip);
if (clientSettings.encoding == "NVENC") {
$("#encodingDrop").html("Encoding (Nvidia)");
} else if(clientSettings.encoding == "AMDVCE"){
} else if (clientSettings.encoding == "AMDVCE") {
$("#encodingDrop").html("Encoding (AMD)")
} else if(clientSettings.encoding == "QSV"){
} else if (clientSettings.encoding == "QSV") {
$("#encodingDrop").html("Encoding (Intel)");
} else {
$("#encodingDrop").html("Encoding (CPU)");

Binary file not shown.

View file

@ -158,6 +158,8 @@ ipcMain.on('autoChangeResolutionOn', (event, fullMessage) => {
function changeScreenRes(width, height) {
var df = __dirname + "\\lib\\ChangeScreenResolution.exe"
exec(df + " /w=" + width + " /h=" + height + " /d=0");
screenWidth = width;
screenHeight = height;
}
ipcMain.on('autoChangeResolutionOff', (event, fullMessage) => {
@ -191,11 +193,13 @@ function killStream() {
if (ffmpegAudioProcess) {
ffmpegAudioProcess.kill();
}
clientSender.send("close");
}
function startStreamer(arg) {
screenWidth = mainScreen.bounds.width * screen.getPrimaryDisplay().scaleFactor;
screenHeight = mainScreen.bounds.height * screen.getPrimaryDisplay().scaleFactor;
ip = arg.ip
quality = arg.q;
hidStreamClient = new net.Socket();
@ -212,8 +216,6 @@ function startStreamer(arg) {
if (usingVideo) {
if (autoChangeResolution && !restartingStream) {
changeScreenRes("1280", "720");
screenWidth = "1280";
screenHeight = "720";
}
var fps = 60;
if (limitFPS) {
@ -221,7 +223,7 @@ function startStreamer(arg) {
}
var ffmpegVideoArgs = [];
if (encoding == "NVENC") { //Nvidia Encoding
ffmpegVideoArgs = ["-probesize", "50M", "-hwaccel", "auto", "-f", "gdigrab", "-framerate", fps, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-c:v", "h264_nvenc", "-gpu", "0", "-rc", "cbr_ld_hq", "-zerolatency", "1", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-cq:v", "19", "-g", "999999", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / (fps / 4)) + "M", "tcp://" + ip + ":2222"];
ffmpegVideoArgs = ["-probesize", "50M", "-hwaccel", "auto", "-f", "gdigrab", "-framerate", fps, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-c:v", "h264_nvenc", "-gpu", "0", "-rc", "constqp/cbr/vbr", "-zerolatency", "1", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-cq:v", "19", "-g", "999999", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / (fps / 4)) + "M", "tcp://" + ip + ":2222"];
log("Using Nvidia Encoding");
} else if (encoding == "AMDVCE") { //AMD Video Coding Engine
ffmpegVideoArgs = ["-probesize", "50M", "-hwaccel", "auto", "-f", "gdigrab", "-framerate", fps, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-c:v", "h264_amf", "-usage", "1", "-rc", "cbr", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / (fps / 4)) + "M", "tcp://" + ip + ":2222"];
@ -251,7 +253,6 @@ function startStreamer(arg) {
if (autoChangeResolution && !restartingStream) {
changeScreenRes(originalW, originalH);
}
clientSender.send("close");
});
}
if (usingAudio) {
@ -268,7 +269,6 @@ function startStreamer(arg) {
});
ffmpegAudioProcess.on('close', (code) => {
log(`AudioProcess process exited with code ${code}`);
clientSender.send("close");
});
}
@ -601,10 +601,8 @@ function handleTouchInput(hid) {
var touchX1 = hid.get("touchX1");
var touchY1 = hid.get("touchY1");
if (touchX1 && touchY1) {
touchX1 -= 15;
touchY1 -= 15;
touchX1 = Math.floor(screenWidth * (touchX1 / 1280))
touchY1 = Math.floor(screenHeight * (touchY1 / 720))
touchX1 = Math.floor(touchX1 * (screenWidth / 1280))
touchY1 = Math.floor(touchY1 * (screenHeight / 720))
if (!touchX1old) touchX1old = touchX1;
if (!touchY1old) touchY1old = touchY1;
var touchX2 = hid.get("touchX2");
@ -728,7 +726,7 @@ function connectHID() {
controllerIds = [];
} catch (error) {
}
killStream();
// killStream();
});
}

View file

@ -70,10 +70,10 @@ void gamePadSend(JoyConSocket *connection)
pkg.rJoyX4 = (int32_t)states[3].state.analog_stick_r.x;
pkg.rJoyY4 = (int32_t)states[3].state.analog_stick_r.y;
printf("%d %d %d %d\n", pkg.lJoyX1, pkg.lJoyY1, pkg.rJoyX1, pkg.rJoyY1);
printf("%d %d %d %d\n", pkg.lJoyX2, pkg.lJoyY2, pkg.rJoyX2, pkg.rJoyY2);
printf("%d %d %d %d\n", pkg.lJoyX3, pkg.lJoyY3, pkg.rJoyX3, pkg.rJoyY3);
printf("%d %d %d %d\n", pkg.lJoyX4, pkg.lJoyY4, pkg.rJoyX4, pkg.rJoyY4);
// printf("%d %d %d %d\n", pkg.lJoyX1, pkg.lJoyY1, pkg.rJoyX1, pkg.rJoyY1);
// printf("%d %d %d %d\n", pkg.lJoyX2, pkg.lJoyY2, pkg.rJoyX2, pkg.rJoyY2);
// printf("%d %d %d %d\n", pkg.lJoyX3, pkg.lJoyY3, pkg.rJoyX3, pkg.rJoyY3);
// printf("%d %d %d %d\n", pkg.lJoyX4, pkg.lJoyY4, pkg.rJoyX4, pkg.rJoyY4);
HidTouchScreenState touchState = {0};
if (hidGetTouchScreenStates(&touchState, 1))
@ -83,7 +83,7 @@ void gamePadSend(JoyConSocket *connection)
pkg.touchX2 = (uint32_t)touchState.touches[1].x;
pkg.touchY2 = (uint32_t)touchState.touches[1].y;
}
printf("%d %d %d %d\n", pkg.touchX1, pkg.touchY1, pkg.touchX2, pkg.touchY2);
// printf("%d %d %d %d\n", pkg.touchX1, pkg.touchY1, pkg.touchX2, pkg.touchY2);
// HidSixAxisSensorState sixaxis = {0};
// u64 style_set = padGetStyleSet(&pad);
// if (style_set & HidNpadStyleTag_NpadHandheld)