mirror of
https://github.com/DevL0rd/SkyNX
synced 2024-11-22 02:53:04 +00:00
added Fps limiter
This commit is contained in:
parent
c4b571f4e0
commit
ce26ded7c2
5 changed files with 44 additions and 8 deletions
|
@ -17,6 +17,7 @@ var hidStreamClient = new net.Socket();
|
|||
var usingVideo = true;
|
||||
var usingAudio = true;
|
||||
var abxySwap = false;
|
||||
var limitFPS = false;
|
||||
var encoding = "CPU";
|
||||
function connect() {
|
||||
hidStreamClient.connect({
|
||||
|
@ -64,12 +65,16 @@ function startAudioProcess() {
|
|||
});
|
||||
}
|
||||
function startVideoProcess() {
|
||||
var fps = 60;
|
||||
if (limitFPS) {
|
||||
fps = 30;
|
||||
}
|
||||
var ffmpegVideoArgs = [];
|
||||
if (encoding == "NVENC") {
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-f", "gdigrab", "-framerate", "60", "-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", 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"];
|
||||
console.log("Using Nvidia Encoding");
|
||||
} else {
|
||||
ffmpegVideoArgs = ["-probesize", "50M", "-threads", "0", "-f", "gdigrab", "-framerate", "60", "-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", 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"];
|
||||
console.log("Using CPU Encoding");
|
||||
}
|
||||
ffmpegProcess = spawn(
|
||||
|
@ -413,6 +418,11 @@ if (args.length > 1) {
|
|||
} else {
|
||||
abxySwap = false;
|
||||
}
|
||||
if (args.includes("/limitFPS")) {
|
||||
limitFPS = true;
|
||||
} else {
|
||||
limitFPS = false;
|
||||
}
|
||||
if (args.includes("/e") && args[args.indexOf("/e") + 1]) {
|
||||
encoding = args[args.indexOf("/e") + 1];
|
||||
} else {
|
||||
|
|
|
@ -69,7 +69,8 @@
|
|||
<input id="disableVideo" type="checkbox">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<label class="form-check-label" for="rainbowEnabled">
|
||||
<label class="form-check-label" for="disableVideo"
|
||||
title="Great for using you switch as a controller dongle">
|
||||
Disable Video
|
||||
</label>
|
||||
</div>
|
||||
|
@ -78,7 +79,7 @@
|
|||
<input id="disableAudio" type="checkbox">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<label class="form-check-label" for="rainbowEnabled">
|
||||
<label class="form-check-label" for="disableAudio">
|
||||
Disable Audio
|
||||
</label>
|
||||
</div>
|
||||
|
@ -87,10 +88,20 @@
|
|||
<input id="abxySwap" type="checkbox">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<label class="form-check-label" for="rainbowEnabled">
|
||||
<label class="form-check-label" for="abxySwap" title="Makes your controllers labels match xBox controls">
|
||||
Swap A-B X-Y
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="switch">
|
||||
<input id="limitFPS" type="checkbox">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<label class="form-check-label" for="limitFPS"
|
||||
title="Great when streaming emulators or games running at 30.">
|
||||
30Fps Limit
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -11,13 +11,13 @@ ipcRenderer.on('started', function (event, data) {
|
|||
})
|
||||
var running = false;
|
||||
function connect() {
|
||||
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding });
|
||||
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS });
|
||||
}
|
||||
function disconnect() {
|
||||
ipcRenderer.send('kill');
|
||||
}
|
||||
function restart() {
|
||||
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding });
|
||||
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS });
|
||||
}
|
||||
$('#startBtn').click(function () {
|
||||
if (!running) {
|
||||
|
|
|
@ -44,6 +44,9 @@ function initSettings() {
|
|||
if (!clientSettings.hasOwnProperty("abxySwap")) {
|
||||
clientSettings.abxySwap = false;
|
||||
}
|
||||
if (!clientSettings.hasOwnProperty("limitFPS")) {
|
||||
clientSettings.limitFPS = false;
|
||||
}
|
||||
if (!clientSettings.hasOwnProperty("encoding")) {
|
||||
clientSettings.encoding = "CPU";
|
||||
}
|
||||
|
@ -73,6 +76,7 @@ function applyClientSettings() {
|
|||
$('#disableVideo').prop("checked", clientSettings.disableVideo);
|
||||
$('#disableAudio').prop("checked", clientSettings.disableAudio);
|
||||
$('#abxySwap').prop("checked", clientSettings.abxySwap);
|
||||
$('#limitFPS').prop("checked", clientSettings.limitFPS);
|
||||
$("#ipInput").val(clientSettings.ip);
|
||||
if (clientSettings.encoding == "NVENC") {
|
||||
$("#encodingDrop").html("Encoding (Nvidia)");
|
||||
|
@ -190,6 +194,15 @@ $("#abxySwap").on('change', function () {
|
|||
saveClientSettings();
|
||||
applyClientSettings();
|
||||
});
|
||||
$("#limitFPS").on('change', function () {
|
||||
clientSettings.limitFPS = $("#limitFPS").prop("checked");
|
||||
if (running) {
|
||||
restart();
|
||||
}
|
||||
saveClientSettings();
|
||||
applyClientSettings();
|
||||
});
|
||||
|
||||
$("#settings-btn").click(function () {
|
||||
$(".contentArea").hide();
|
||||
$("#settings").fadeIn(400);
|
||||
|
|
|
@ -119,7 +119,9 @@ function startStreamer(arg) {
|
|||
args.push("/e");
|
||||
args.push("NVENC");
|
||||
}
|
||||
|
||||
if (arg.limitFPS) {
|
||||
args.push("/limitFPS");
|
||||
}
|
||||
streamerProcess = spawn(
|
||||
"./NxStreamingService.exe",
|
||||
args,
|
||||
|
|
Loading…
Reference in a new issue