NVENC support

This commit is contained in:
KingKDot
2026-06-06 16:08:28 -05:00
parent 7f8e5ff333
commit de67516285
29 changed files with 8820 additions and 14 deletions
@@ -38,6 +38,7 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
const cursorCtrl = document.getElementById("cursorCtrl");
const duplicationCtrl = document.getElementById("duplicationCtrl");
const resolutionSelect = document.getElementById("resolutionSelect");
const targetFpsSelect = document.getElementById("targetFpsSelect");
const smoothingSlider = document.getElementById("smoothingSlider");
const smoothingValue = document.getElementById("smoothingValue");
const qualitySlider = document.getElementById("qualitySlider");
@@ -1101,14 +1102,28 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
const codec = q >= 100 ? "raw" : (prefersH264 ? "h264" : "jpeg");
console.debug("rd: pushQuality val=", val, "q=", q, "codec=", codec);
setCodecModeLabel(codec, "requested");
if (codec === "h264") {
ensureDuplicationForH264();
}
sendCmd("desktop_set_quality", { quality: q, codec });
}
function ensureDuplicationForH264() {
if (!duplicationCtrl || duplicationCtrl.disabled) return;
const isWindows = clientOs.includes("windows") || clientOs.includes("win");
if (!isWindows || duplicationCtrl.checked) return;
duplicationCtrl.checked = true;
sendCmd("desktop_set_duplication", { enabled: true });
}
if (codecH264) {
codecH264.addEventListener("change", function () {
resetH264SessionState();
prefersH264 = !!codecH264.checked && typeof VideoDecoder === "function";
localStorage.setItem(codecPrefKey, prefersH264 ? "1" : "0");
if (prefersH264) {
ensureDuplicationForH264();
}
if (!prefersH264) {
destroyVideoDecoder();
h264LowFpsStreak = 0;
@@ -1127,12 +1142,29 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
}
}
function selectedTargetFps() {
const fps = Number(targetFpsSelect?.value || 120);
return Number.isFinite(fps) ? Math.max(1, Math.min(240, Math.floor(fps))) : 120;
}
function pushTargetFps() {
const fps = selectedTargetFps();
console.debug("rd: pushTargetFps fps=", fps);
sendCmd("desktop_set_fps", { fps });
}
if (resolutionSelect) {
resolutionSelect.addEventListener("change", function () {
pushResolution();
});
}
if (targetFpsSelect) {
targetFpsSelect.addEventListener("change", function () {
pushTargetFps();
});
}
displaySelect.addEventListener("change", function () {
console.debug("rd: select display", displaySelect.value);
sendCmd("desktop_select_display", {
@@ -1163,6 +1195,7 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
display: displaySelect?.value ?? "",
quality: qualitySlider?.value ?? "",
resolution: resolutionSelect?.value ?? "",
targetFps: targetFpsSelect?.value ?? "",
prefersH264,
duplication: !!duplicationCtrl?.checked,
clientOs,
@@ -1182,6 +1215,10 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
if (qualitySlider) {
pushQuality(qualitySlider.value);
}
if (prefersH264) {
ensureDuplicationForH264();
}
pushTargetFps();
pushResolution();
desiredStreaming = true;
lastFrameAt = 0;
+16
View File
@@ -176,6 +176,22 @@
<option value="relayed">WebRTC Relayed</option>
</select>
</div>
<div class="flex items-center gap-2 mb-2">
<label class="text-sm text-slate-300 w-20" for="targetFpsSelect">Max FPS</label>
<select
id="targetFpsSelect"
class="flex-1 bg-slate-800 border border-slate-700 rounded px-2 py-1 text-sm text-slate-100"
title="Target capture and encoder frame rate"
>
<option value="30">30 fps</option>
<option value="60">60 fps</option>
<option value="90">90 fps</option>
<option value="120" selected>120 fps</option>
<option value="144">144 fps</option>
<option value="165">165 fps</option>
<option value="240">240 fps</option>
</select>
</div>
<div class="flex items-center justify-between gap-2">
<label class="flex items-center gap-2 text-sm text-slate-200" title="Prefer H.264 when available; disable to force JPEG">
<input type="checkbox" id="codecH264" checked /> H.264