工具:完善串流对照测试并同步开发进度

This commit is contained in:
songyiming committed 2026-11-03 17:50:31 +08:00
1 parent 853bcb7574
commit b2de05c6a6
6 files changed
+75 -8

No files matched your search

+14 -5
View File
@@ -6,9 +6,11 @@ task_root="${VDI_RKMPP_BUILD_ROOT:-$HOME/vdi-build/rkmpp-experiment}"
label="${1:?label required}"
fps="${2:?FPS required}"
priority="${3:-0}"
hold="${VDI_BENCH_HOLD_SECONDS:-12}"
[[ "$label" =~ ^[a-zA-Z0-9-]+$ ]] || exit 2
[[ "$fps" = 30 || "$fps" = 60 ]] || exit 2
[[ "$fps" = 30 || "$fps" = 45 || "$fps" = 60 ]] || exit 2
[[ "$priority" = 0 || "$priority" = 1 ]] || exit 2
[[ "$hold" =~ ^[0-9]+$ ]] && ((hold <= 180)) || exit 2
exec 9>"$task_root/mouse-bench.lock"
flock -n 9 || { echo 'Another benchmark is active'; exit 1; }
if pgrep -f '^/home/armbian/vdi-build/rkmpp-experiment/build/moonlight/app/moonlight.* stream ' >/dev/null; then
@@ -20,8 +22,12 @@ export LD_LIBRARY_PATH="$task_root/runtime/lib:$task_root/deps/usr/lib/aarch64-l
export QML2_IMPORT_PATH="$task_root/deps/usr/lib/aarch64-linux-gnu/qt5/qml"
export QT_PLUGIN_PATH="$task_root/deps/usr/lib/aarch64-linux-gnu/qt5/plugins"
export H264_DECODER_HINT=h264_rkmpp HEVC_DECODER_HINT=hevc_rkmpp
export VDI_LATEST_FRAME=1 VDI_INPUT_TIMING=1 VDI_INPUT_PRIORITY="$priority"
export VDI_LATEST_FRAME="${VDI_LATEST_FRAME:-1}" VDI_INPUT_TIMING=1 VDI_INPUT_PRIORITY="$priority"
export GL_IS_SLOW=0 SDL_RENDER_DRIVER=opengles2 SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=1
sync_args=(--no-vsync --no-frame-pacing)
if [ "${VDI_BENCH_VSYNC:-0}" = 1 ]; then
sync_args=(--vsync --no-frame-pacing)
fi
client="${VDI_RKMPP_CLIENT:-$task_root/build/moonlight/app/moonlight}"
mkdir -p "$task_root/mouse-bench"
log="$task_root/mouse-bench/$label.log"
@@ -43,8 +49,8 @@ trap 'exit 130' INT
trap 'exit 143' TERM
"$client" stream 192.168.1.70 Desktop --resolution 2560x1440 --fps "$fps" \
--bitrate 30000 --display-mode fullscreen --video-codec H.264 \
--video-decoder hardware --absolute-mouse --keep-awake --no-vsync \
--no-frame-pacing --audio-on-host > "$log" 2>&1 &
--video-decoder hardware --absolute-mouse --keep-awake "${sync_args[@]}" \
--audio-on-host > "$log" 2>&1 &
child=$!
ready=0
for ((i=0;i<35;i++)); do
@@ -56,7 +62,10 @@ test "$ready" = 1 || { echo 'No video readiness'; exit 1; }
echo "Ready: $label; injecting motion"
python3 "$task_root/mouse-bench/inject-mouse-sweep.py"
python3 "$task_root/mouse-bench/inject-input-burst.py"
sleep 12
for ((i=0;i<hold;i++)); do
kill -0 "$child" || { echo 'Benchmark stream exited during hold'; exit 1; }
sleep 1
done
# Do not send the exit chord into an unrelated foreground application.
focus_pid=$(xdotool getwindowfocus getwindowpid 2>/dev/null || true)
if [ "$focus_pid" != "$child" ]; then
+7 -2
View File
@@ -4,14 +4,19 @@ import base64
from pathlib import Path
import runpy
import sys
import re
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("action", choices=["Query", "List", "Apply", "Restore"])
parser.add_argument("--hz", type=int, default=60)
parser.add_argument("--backup-tag", default="", help="Separate backup for this verification run")
args = parser.parse_args()
if not 24 <= args.hz <= 240:
parser.error("--hz must be in 24..240")
if args.backup_tag and not re.fullmatch(r"[A-Za-z0-9_-]{1,64}", args.backup_tag):
parser.error("--backup-tag must contain 1..64 letters, digits, underscores or hyphens")
backup_name = "display-before" + ("-" + args.backup_tag if args.backup_tag else "") + ".json"
root = Path(__file__).resolve().parent
term = runpy.run_path(str(root / "pve_term_exec.py"))
vm = runpy.run_path(str(root / "pve_vm.py"))
@@ -33,7 +38,7 @@ $rule=New-Object Security.AccessControl.FileSystemAccessRule($user,'Modify','Con
$acl.SetAccessRule($rule)
Set-Acl -LiteralPath $folder -AclObject $acl
[IO.File]::WriteAllBytes("$folder\mode.ps1",[Convert]::FromBase64String('__VDI_PAYLOAD__'))
$run="try { & '$folder\mode.ps1' -Action __VDI_ACTION__ -RefreshRate __VDI_HZ__ | Out-File -Encoding utf8 -Width 300 '$folder\mode-result.txt' } catch { `$_ | Out-String | Out-File -Encoding utf8 -Width 300 '$folder\mode-result.txt'; exit 1 }"
$run="try { & '$folder\mode.ps1' -Action __VDI_ACTION__ -RefreshRate __VDI_HZ__ -BackupPath '$folder\__VDI_BACKUP__' | Out-File -Encoding utf8 -Width 300 '$folder\mode-result.txt' } catch { `$_ | Out-String | Out-File -Encoding utf8 -Width 300 '$folder\mode-result.txt'; exit 1 }"
$encoded=[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($run))
$action=New-ScheduledTaskAction -Execute powershell.exe -Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand $encoded"
$principal=New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited
@@ -53,7 +58,7 @@ try {
Stop-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue
Unregister-ScheduledTask -TaskName $task -Confirm:$false
}
""".replace("__VDI_ACTION__", args.action).replace("__VDI_HZ__", str(args.hz)).replace("__VDI_PAYLOAD__", payload)
""".replace("__VDI_ACTION__", args.action).replace("__VDI_HZ__", str(args.hz)).replace("__VDI_BACKUP__", backup_name).replace("__VDI_PAYLOAD__", payload)
out, error = vm["agent"](ticket, csrf, ["powershell.exe", "-NoProfile", "-Command", command])
print(out)
if error or "task_result=0" not in out: