AMD Encoding Fix + Incorrect monitor ID fix + Vsync options + General Changes to Improve Experience

Fixed the AMD bug listed within the issue tracker. "Undefined constant or missing '(' in 'vbr'" assuming vbr rc was removed, therefore I've changed this to vbr_latency.

Added some flags to improve performance (Unsure if this has worked or not, however AMD encoding appears to be working relatively well all considering!) Also tinkered with amd hevc although this isn't good and causes heavy latency most likely due to 264 -> 265 conversion.

Monitor issue bugged me as it was simply a windows issue causing my primary monitor to instead be ID 1 where SkyNX assumed it was 0.  Added user input field above set screen to 720p where they can specify another monitor.

Users can now specify a  vsync option, this is experimental tbh, and was just something I noticed could be tinkered with from the users point of view.

Made window resizable due to issues I had with the user interface randomly going smaller (Unsure where this bug is coming from, may be due to multi-monitor setup)
This commit is contained in:
williamhackett0 2022-05-01 18:09:59 +01:00
parent 971a02040b
commit efa5005524
6 changed files with 4372 additions and 44 deletions

View file

@ -2,7 +2,7 @@
/* GitHub: https://github.com/DevL0rd */ /* GitHub: https://github.com/DevL0rd */
html { html {
background: transparent; background: transparent;
height: 100%; height: 1200px;
border-top-left-radius: 5px; border-top-left-radius: 5px;
border-top-right-radius: 5px; border-top-right-radius: 5px;
border-bottom-left-radius: 8px; border-bottom-left-radius: 8px;
@ -25,12 +25,11 @@ body {
textarea:focus, input:focus{ textarea:focus, input:focus{
outline: none; outline: none;
} }
#content { #content {
background: linear-gradient(to bottom, rgba(30,30,30,0.9) 0%,rgba(51,51,51,0.8) 67%,rgba(51,51,51,0.8) 100%); background: linear-gradient(to bottom, rgba(30,30,30,0.9) 0%,rgba(51,51,51,0.8) 67%,rgba(51,51,51,0.8) 100%);
height: calc(100% - 57px); height: 100%;
overflow: auto;
width: 100%; width: 100%;
} }
#title-bar { #title-bar {
@ -213,11 +212,12 @@ textarea:focus, input:focus{
position: absolute; position: absolute;
top: 32px; top: 32px;
left: 50px; left: 50px;
height: calc(100% - 57px); height: 100%;
width: calc(100% - 50px); width: calc(100% - 50px);
background: rgba(50,50,50,0.5); background: rgba(50,50,50,0.5);
overflow: hidden; overflow: hidden;
} }
.contentAreaScrollable{ .contentAreaScrollable{
overflow: hidden; overflow: hidden;
overflow-y: auto; overflow-y: auto;

View file

@ -56,11 +56,25 @@
<div class="dropdown-menu" aria-labelledby="encodingDrop"> <div class="dropdown-menu" aria-labelledby="encodingDrop">
<a class="dropdown-item" href="javascript:setEncoding('CPU')">CPU Encoding</a> <a class="dropdown-item" href="javascript:setEncoding('CPU')">CPU Encoding</a>
<a class="dropdown-item" href="javascript:setEncoding('NVENC')">Nvidia Encoding</a> <a class="dropdown-item" href="javascript:setEncoding('NVENC')">Nvidia Encoding</a>
<a class="dropdown-item" href="javascript:setEncoding('AMDVCE')">AMD Encoding</a> <a class="dropdown-item" href="javascript:setEncoding('AMDVCE')">AMD Encoding (AMF)</a>
<a class="dropdown-item" href="javascript:setEncoding('AMDHEVC')">AMD Encoding (HEVC)</a>
<a class="dropdown-item" href="javascript:setEncoding('QSV')">Intel Encoding</a> <a class="dropdown-item" href="javascript:setEncoding('QSV')">Intel Encoding</a>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle btn-block" type="button" id="vsyncDrop"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Vsync (VFR)
</button>
<div class="dropdown-menu" aria-labelledby="vsyncDrop">
<a class="dropdown-item" href="javascript:setVsync('passthrough')">Passthrough</a>
<a class="dropdown-item" href="javascript:setVsync('drop')">Drop</a>
<a class="dropdown-item" href="javascript:setVsync('vfr')">VFR</a>
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<button id="startBtn" type="button" class="btn btn-dark btn-lg btn-block">Start Streamer</button> <button id="startBtn" type="button" class="btn btn-dark btn-lg btn-block">Start Streamer</button>
</div> </div>
@ -140,6 +154,10 @@
<hr /> <hr />
<h2>General</h2> <h2>General</h2>
<hr /> <hr />
<div class="form-group">
<label for="monitorInput">Monitor ID (0, 1, etc)</label>
<input id="monitorInput" title="Typically your primary monitor is ID 0, however due to Windows stuff this isn't always the case... MUST BE A NUMBER!" type="text" class="form-control" placeholder="0">
</div>
<div class="form-group"> <div class="form-group">
<label class="switch"> <label class="switch">
<input id="autoChangeResolution" type="checkbox"> <input id="autoChangeResolution" type="checkbox">

View file

@ -6,7 +6,7 @@ function connect() {
$('#startBtn').addClass('btn-danger').removeClass('btn-dark'); $('#startBtn').addClass('btn-danger').removeClass('btn-dark');
$("#startBtn").html("End Streamer"); $("#startBtn").html("End Streamer");
running = true; running = true;
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS, mouseControl: clientSettings.mouseControl }); ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS, mouseControl: clientSettings.mouseControl, vsync: clientSettings.vsync, monitorID: clientSettings.monitorID});
} }
function disconnect() { function disconnect() {
$("#startBtn").addClass('btn-dark').removeClass('btn-danger'); $("#startBtn").addClass('btn-dark').removeClass('btn-danger');
@ -16,7 +16,7 @@ function disconnect() {
} }
function restart() { function restart() {
if (running) { if (running) {
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS, mouseControl: clientSettings.mouseControl }); ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality, disableVideo: clientSettings.disableVideo, disableAudio: clientSettings.disableAudio, abxySwap: clientSettings.abxySwap, encoding: clientSettings.encoding, limitFPS: clientSettings.limitFPS, mouseControl: clientSettings.mouseControl, vsync: clientSettings.vsync, monitorID: clientSettings.monitorID});
} }
} }
$('#startBtn').click(function () { $('#startBtn').click(function () {

View file

@ -32,6 +32,9 @@ function initSettings() {
if (!clientSettings.hasOwnProperty("ip")) { if (!clientSettings.hasOwnProperty("ip")) {
clientSettings.ip = "0.0.0.0"; clientSettings.ip = "0.0.0.0";
} }
if (!clientSettings.hasOwnProperty("monitorID")) {
clientSettings.ip = "0";
}
if (!clientSettings.hasOwnProperty("quality")) { if (!clientSettings.hasOwnProperty("quality")) {
clientSettings.quality = 5; clientSettings.quality = 5;
} }
@ -62,6 +65,9 @@ function initSettings() {
if (!clientSettings.hasOwnProperty("autoStartup")) { if (!clientSettings.hasOwnProperty("autoStartup")) {
clientSettings.autoStartup = false; clientSettings.autoStartup = false;
} }
if (!clientSettings.hasOwnProperty("vsync")) {
clientSettings.vsync = "vfr";
}
applyClientSettings(); applyClientSettings();
} }
@ -90,16 +96,38 @@ function applyClientSettings() {
ipcRenderer.send("autoChangeResolutionOff") ipcRenderer.send("autoChangeResolutionOff")
} }
$("#ipInput").val(clientSettings.ip); $("#ipInput").val(clientSettings.ip);
$("#monitorInput").val(clientSettings.monitorID);
if (clientSettings.encoding == "NVENC") { if (clientSettings.encoding == "NVENC") {
$("#encodingDrop").html("Encoding (Nvidia)"); $("#encodingDrop").html("Encoding (Nvidia)");
} else if (clientSettings.encoding == "AMDVCE") { } else if (clientSettings.encoding == "AMDVCE") {
$("#encodingDrop").html("Encoding (AMD)") $("#encodingDrop").html("Encoding (AMD amf)")
} else if (clientSettings.encoding == "QSV") { }
else if (clientSettings.encoding == "AMDHEVC")
{
$("#encodingDrop").html("Encoding (AMD hevc)")
}
else if (clientSettings.encoding == "QSV") {
$("#encodingDrop").html("Encoding (Intel)"); $("#encodingDrop").html("Encoding (Intel)");
} else { } else {
$("#encodingDrop").html("Encoding (CPU)"); $("#encodingDrop").html("Encoding (CPU)");
clientSettings.encoding = "CPU"; clientSettings.encoding = "CPU";
} }
//Vsync options
switch(clientSettings.vsync)
{
case "passthrough":
$("#vsyncDrop").html("Vsync (Passthrough)")
break
case "drop":
$("#vsyncDrop").html("Vsync (Drop)")
break
case "vfr":
$("#vsyncDrop").html("Vsync (VFR)")
break
}
if (clientSettings.mouseControl == "ANALOG") { if (clientSettings.mouseControl == "ANALOG") {
$("#mouseControlDrop").html("Mouse Control (Analog)"); $("#mouseControlDrop").html("Mouse Control (Analog)");
} else if (clientSettings.mouseControl == "GYRO") { } else if (clientSettings.mouseControl == "GYRO") {
@ -193,6 +221,12 @@ $(document).on('input', '#ipInput', function () {
clientSettings.ip = $(this).val(); clientSettings.ip = $(this).val();
saveClientSettings(); saveClientSettings();
}); });
$(document).on('input', '#monitorInput', function () {
clientSettings.monitorID = $(this).val();
saveClientSettings();
});
$("#disableVideo").on('change', function () { $("#disableVideo").on('change', function () {
clientSettings.disableVideo = $("#disableVideo").prop("checked"); clientSettings.disableVideo = $("#disableVideo").prop("checked");
if (running) { if (running) {
@ -245,6 +279,17 @@ function setEncoding(encoding) {
saveClientSettings(); saveClientSettings();
applyClientSettings(); applyClientSettings();
} }
function setVsync(vsync)
{
clientSettings.vsync = vsync;
if (running) {
restart();
}
saveClientSettings();
applyClientSettings();
}
function setMouseControl(mouseControl) { function setMouseControl(mouseControl) {
clientSettings.mouseControl = mouseControl; clientSettings.mouseControl = mouseControl;
if (running) { if (running) {

View file

@ -18,7 +18,8 @@ var ansi_up = new AU.default;
let mainWindow let mainWindow
var minimizeToTray = false; var minimizeToTray = false;
var autoChangeResolution = false; var autoChangeResolution = false;
var ip = "0.0.0.0" var ip = "0.0.0.0";
var monitorID = "0";
var quality = 5; var quality = 5;
var hidStreamClient = null; var hidStreamClient = null;
var usingVideo = true; var usingVideo = true;
@ -26,6 +27,7 @@ var usingAudio = true;
var abxySwap = false; var abxySwap = false;
var limitFPS = false; var limitFPS = false;
var encoding = "CPU"; var encoding = "CPU";
var vsync = "vfr";
var screenWidth = 1280; var screenWidth = 1280;
var screenHeight = 720; var screenHeight = 720;
var screenScale = 1; var screenScale = 1;
@ -57,10 +59,10 @@ function createWindow() {
// height: mainWindowState.height, // height: mainWindowState.height,
show: true, show: true,
width: 500, width: 500,
height: 320, height: 400,
frame: false, frame: false,
transparent: true, // needed for windows rounded edges transparent: true, // needed for windows rounded edges
resizable: false, resizable: true,
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
enableRemoteModule: true, enableRemoteModule: true,
@ -160,7 +162,7 @@ ipcMain.on('autoChangeResolutionOn', (event, fullMessage) => {
function changeScreenRes(width, height) { function changeScreenRes(width, height) {
var df = __dirname + "\\lib\\ChangeScreenResolution.exe" var df = __dirname + "\\lib\\ChangeScreenResolution.exe"
exec(df + " /w=" + width + " /h=" + height + " /d=0"); exec(df + " /w=" + width + " /h=" + height + " /d=" + monitorID);
screenWidth = width; screenWidth = width;
screenHeight = height; screenHeight = height;
} }
@ -211,19 +213,32 @@ function startStreamer() {
var bitrate = quality * 1024; var bitrate = quality * 1024;
bitrate = bitrate + "k"; bitrate = bitrate + "k";
console.log(bitrate) console.log(bitrate)
if (encoding == "NVENC") {
ffmpegVideoArgs = ["-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", "vfr", "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-c:v", "h264_nvenc", "-gpu", "0", "-rc", "vbr", "-zerolatency", "1", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-cq:v", "19", "-g", "999999", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"]; if (encoding == "NVENC")
{
ffmpegVideoArgs = ["-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", vsync, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-c:v", "h264_nvenc", "-gpu", "0", "-rc", "vbr", "-zerolatency", "1", "-f", "h264", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-cq:v", "19", "-g", "999999", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"];
log("Using Nvidia Encoding"); log("Using Nvidia Encoding");
} else if (encoding == "AMDVCE") { //AMD Video Coding Engine } else if (encoding == "AMDVCE") //AMD Video Coding Engine
ffmpegVideoArgs = ["-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", "vfr", "-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", "vbr", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"]; {
log("Using AMD Video Coding Engine"); ffmpegVideoArgs = ["-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", vsync, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-c:v", "h264_amf", "-usage", "ultralowlatency", "-quality", "speed", "-rc", "vbr_latency", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"];
} else if (encoding == "QSV") { log("Using AMD Video Coding Engine (amf)");
ffmpegVideoArgs = ["-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", "vfr", "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-c:v", "h264_qsv", "-preset", "faster", "-profile", "baseline", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"]; }
else if(encoding == "AMDHEVC")
{
ffmpegVideoArgs = ["-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", vsync, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-c:v", "hevc_amf", "-usage", "ultralowlatency", "-quality", "speed", "-rc", "vbr_latency", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"];
log("Using AMD Video Coding Engine (hevc)");
}
else if (encoding == "QSV")
{
ffmpegVideoArgs = ["-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", vsync, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-c:v", "h264_qsv", "-preset", "faster", "-profile", "baseline", "-vf", "scale=1280x720", "-pix_fmt", "yuv420p", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"];
log("Using Intel QSV Encoding"); log("Using Intel QSV Encoding");
} else { //CPU Software Encoding }
ffmpegVideoArgs = ["-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", "vfr", "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-crf", "18", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", "nal-hrd=vbr:opencl=true", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"]; else
{ //CPU Software Encoding
ffmpegVideoArgs = ["-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-hwaccel", "auto", "-y", "-f", "gdigrab", "-framerate", fps, "-vsync", vsync, "-video_size", screenWidth + "x" + screenHeight, "-offset_x", "0", "-offset_y", "0", "-draw_mouse", "1", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-crf", "18", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", "nal-hrd=vbr:opencl=true", "-b:v", bitrate, "-minrate", bitrate, "-maxrate", bitrate, "-bufsize", bitrate, "tcp://" + ip + ":2222"];
log("Using CPU Encoding"); log("Using CPU Encoding");
} }
ffmpegProcess = spawn( ffmpegProcess = spawn(
__dirname + "/lib/ffmpeg.exe", __dirname + "/lib/ffmpeg.exe",
ffmpegVideoArgs, ffmpegVideoArgs,
@ -276,7 +291,9 @@ function setArgs(arg) {
limitFPS = arg.limitFPS; limitFPS = arg.limitFPS;
screenScale = screen.getPrimaryDisplay().scaleFactor; screenScale = screen.getPrimaryDisplay().scaleFactor;
mouseControl = arg.mouseControl; mouseControl = arg.mouseControl;
encoding = arg.encoding encoding = arg.encoding;
vsync = arg.vsync;
monitorID = arg.monitorID;
} }
ipcMain.on('connect', (event, arg) => { ipcMain.on('connect', (event, arg) => {
clientSender = event.sender; clientSender = event.sender;

File diff suppressed because it is too large Load diff