mirror of
https://github.com/DevL0rd/SkyNX
synced 2024-11-13 23:17:06 +00:00
auto set screen res. fixed screen capture for higher res
This commit is contained in:
parent
ce26ded7c2
commit
f4113ab863
7 changed files with 105 additions and 8 deletions
BIN
SkyNX-Streamer/NxStreamingService/lib/ChangeScreenResolution.exe
Normal file
BIN
SkyNX-Streamer/NxStreamingService/lib/ChangeScreenResolution.exe
Normal file
Binary file not shown.
|
@ -10,15 +10,14 @@ const vgen = new VGen();
|
|||
const GyroServ = require("./Devlord_modules/GyroServ.js");
|
||||
var ip = "0.0.0.0"
|
||||
var quality = 5;
|
||||
var screenSize = robot.getScreenSize();
|
||||
var sheight = screenSize.height;
|
||||
var swidth = screenSize.width;
|
||||
var hidStreamClient = new net.Socket();
|
||||
var usingVideo = true;
|
||||
var usingAudio = true;
|
||||
var abxySwap = false;
|
||||
var limitFPS = false;
|
||||
var encoding = "CPU";
|
||||
var screenWidth = 1280;
|
||||
var screenHeight = 720;
|
||||
function connect() {
|
||||
hidStreamClient.connect({
|
||||
host: ip,
|
||||
|
@ -71,10 +70,10 @@ function startVideoProcess() {
|
|||
}
|
||||
var ffmpegVideoArgs = [];
|
||||
if (encoding == "NVENC") {
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-f", "gdigrab", "-framerate", fps, "-video_size", swidth + "x" + sheight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-c:v", "h264_nvenc", "-gpu", "0", "-rc", "cbr_ld_hq", "-zerolatency", "true", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / 2) + "M", "tcp://" + ip + ":2222"];
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-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", "true", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / 2) + "M", "tcp://" + ip + ":2222"];
|
||||
console.log("Using Nvidia Encoding");
|
||||
} else {
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-f", "gdigrab", "-framerate", fps, "-video_size", swidth + "x" + sheight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", 'nal-hrd=cbr', "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / 2) + "M", "tcp://" + ip + ":2222"];
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-f", "gdigrab", "-framerate", fps, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", 'nal-hrd=cbr', "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / 2) + "M", "tcp://" + ip + ":2222"];
|
||||
console.log("Using CPU Encoding");
|
||||
}
|
||||
ffmpegProcess = spawn(
|
||||
|
@ -398,6 +397,16 @@ if (args.length > 1) {
|
|||
} else {
|
||||
quality = 5;
|
||||
}
|
||||
if (args.includes("/w") && args[args.indexOf("/w") + 1]) {
|
||||
screenWidth = args[args.indexOf("/w") + 1];
|
||||
} else {
|
||||
screenWidth = 1280;
|
||||
}
|
||||
if (args.includes("/h") && args[args.indexOf("/h") + 1]) {
|
||||
screenHeight = args[args.indexOf("/h") + 1];
|
||||
} else {
|
||||
screenHeight = 720;
|
||||
}
|
||||
if (args.includes("/noVideo")) {
|
||||
usingVideo = false;
|
||||
} else {
|
||||
|
|
|
@ -117,6 +117,18 @@
|
|||
<hr />
|
||||
<h2>General</h2>
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<label class="switch">
|
||||
<input id="autoChangeResolution" type="checkbox">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<label class="form-check-label" for="autoChangeResolution">
|
||||
Set resolution to 1280 X 720 on streamer start.
|
||||
</label>
|
||||
</div>
|
||||
<hr />
|
||||
<h2>Startup</h2>
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<label class="switch">
|
||||
<input id="autoStart" type="checkbox">
|
||||
|
@ -135,6 +147,9 @@
|
|||
Start streamer on startup.
|
||||
</label>
|
||||
</div>
|
||||
<hr />
|
||||
<h2>UI</h2>
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<label class="switch">
|
||||
<input id="rainbowEnabled" type="checkbox">
|
||||
|
|
|
@ -47,6 +47,9 @@ function initSettings() {
|
|||
if (!clientSettings.hasOwnProperty("limitFPS")) {
|
||||
clientSettings.limitFPS = false;
|
||||
}
|
||||
if (!clientSettings.hasOwnProperty("autoChangeResolution")) {
|
||||
clientSettings.autoChangeResolution = true;
|
||||
}
|
||||
if (!clientSettings.hasOwnProperty("encoding")) {
|
||||
clientSettings.encoding = "CPU";
|
||||
}
|
||||
|
@ -77,6 +80,12 @@ function applyClientSettings() {
|
|||
$('#disableAudio').prop("checked", clientSettings.disableAudio);
|
||||
$('#abxySwap').prop("checked", clientSettings.abxySwap);
|
||||
$('#limitFPS').prop("checked", clientSettings.limitFPS);
|
||||
$('#autoChangeResolution').prop("checked", clientSettings.autoChangeResolution);
|
||||
if (clientSettings.autoChangeResolution) {
|
||||
ipcRenderer.send("autoChangeResolutionOn");
|
||||
} else {
|
||||
ipcRenderer.send("autoChangeResolutionOff")
|
||||
}
|
||||
$("#ipInput").val(clientSettings.ip);
|
||||
if (clientSettings.encoding == "NVENC") {
|
||||
$("#encodingDrop").html("Encoding (Nvidia)");
|
||||
|
@ -202,6 +211,11 @@ $("#limitFPS").on('change', function () {
|
|||
saveClientSettings();
|
||||
applyClientSettings();
|
||||
});
|
||||
$("#autoChangeResolution").on('change', function () {
|
||||
clientSettings.autoChangeResolution = $("#autoChangeResolution").prop("checked");
|
||||
saveClientSettings();
|
||||
applyClientSettings();
|
||||
});
|
||||
|
||||
$("#settings-btn").click(function () {
|
||||
$(".contentArea").hide();
|
||||
|
|
|
@ -9,10 +9,14 @@ const isDev = require('electron-is-dev');
|
|||
var AutoLaunch = require('auto-launch');
|
||||
var AU = require('ansi_up');
|
||||
var ansi_up = new AU.default;
|
||||
const { app, BrowserWindow, ipcMain, Menu, Tray } = require('electron')
|
||||
const { app, BrowserWindow, ipcMain, Menu, Tray, screen } = require('electron')
|
||||
let mainWindow
|
||||
var usingUI = true;
|
||||
var minimizeToTray = false;
|
||||
var autoChangeResolution = false;
|
||||
app.commandLine.appendSwitch('high-dpi-support', 'true');
|
||||
//var sr = require('screenres');
|
||||
// sr.set(800, 600);
|
||||
function createWindow() {
|
||||
let mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 500,
|
||||
|
@ -80,7 +84,14 @@ function createWindow() {
|
|||
appIcon.setHighlightMode('always');
|
||||
});
|
||||
}
|
||||
app.on('ready', function () { if (usingUI) setTimeout(createWindow, 300); });
|
||||
var screenWidth;
|
||||
var screenHeight;
|
||||
app.on('ready', function () {
|
||||
if (usingUI) setTimeout(createWindow, 300);
|
||||
var mainScreen = screen.getPrimaryDisplay();
|
||||
screenWidth = mainScreen.bounds.width * screen.getPrimaryDisplay().scaleFactor;
|
||||
screenHeight = mainScreen.bounds.height * screen.getPrimaryDisplay().scaleFactor;
|
||||
});
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
|
@ -101,11 +112,14 @@ var streamerProcess;
|
|||
var clientSender;
|
||||
var streamerProcessIsRunning = false;
|
||||
function startStreamer(arg) {
|
||||
if (autoChangeResolution) {
|
||||
changeScreenRes("1280", "720");
|
||||
}
|
||||
var cwd = './NxStreamingService/';
|
||||
if (!isDev) {
|
||||
cwd = "./resources/app/NxStreamingService"
|
||||
}
|
||||
var args = ["/ip", arg.ip, "/q", arg.q];
|
||||
var args = ["/ip", arg.ip, "/q", arg.q, "/w", screenWidth, "/h", screenHeight];
|
||||
if (arg.disableVideo) {
|
||||
args.push("/noVideo");
|
||||
}
|
||||
|
@ -146,6 +160,9 @@ function startStreamer(arg) {
|
|||
clientSender.send("close");
|
||||
log(`streamerProcess process exited with code ${code}`);
|
||||
streamerProcessIsRunning = false;
|
||||
if (autoChangeResolution) {
|
||||
changeScreenRes(screenWidth, screenHeight);
|
||||
}
|
||||
});
|
||||
}
|
||||
ipcMain.on('connect', (event, arg) => {
|
||||
|
@ -250,7 +267,20 @@ ipcMain.on('autoStartupOff', (event, fullMessage) => {
|
|||
autoLauncher.disable();
|
||||
}
|
||||
});
|
||||
ipcMain.on('autoChangeResolutionOn', (event, fullMessage) => {
|
||||
autoChangeResolution = true;
|
||||
});
|
||||
ipcMain.on('autoChangeResolutionOff', (event, fullMessage) => {
|
||||
if (autoChangeResolution) {
|
||||
changeScreenRes(screenWidth, screenHeight);
|
||||
}
|
||||
autoChangeResolution = false;
|
||||
});
|
||||
|
||||
ipcMain.on("restartComputer", (event, fullMessage) => {
|
||||
exec("shutdown -r -t 0");
|
||||
});
|
||||
function changeScreenRes(width, height) {
|
||||
var df = __dirname + "\\NxStreamingService\\lib\\ChangeScreenResolution.exe"
|
||||
exec(df + " /w=" + width + " /h=" + height + " /d=0");
|
||||
}
|
28
SkyNX-Streamer/package-lock.json
generated
28
SkyNX-Streamer/package-lock.json
generated
|
@ -60,6 +60,14 @@
|
|||
"winreg": "1.2.4"
|
||||
}
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"boolean": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/boolean/-/boolean-3.0.1.tgz",
|
||||
|
@ -279,6 +287,11 @@
|
|||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"formidable": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz",
|
||||
|
@ -457,6 +470,11 @@
|
|||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.1",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
|
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
|
||||
|
@ -604,6 +622,16 @@
|
|||
"truncate-utf8-bytes": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"screenres": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/screenres/-/screenres-2.0.1.tgz",
|
||||
"integrity": "sha512-kPQ+89AvTAmW0U1JVjTFI7vEXDsn3cx9EqXYaaMV9gXon8TMOZkAviTjoT4//0eHgdJj/KDapJFs6i4l5yzngw==",
|
||||
"requires": {
|
||||
"bindings": "^1.2.1",
|
||||
"minimist": "^1.1.1",
|
||||
"nan": "^2.0.9"
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "7.3.2",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
"jquery": "latest",
|
||||
"popper.js": "latest",
|
||||
"readdirp": "latest",
|
||||
"screenres": "^2.0.1",
|
||||
"windows-elevate": "^1.0.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue