串流将平板作为PC第三屏

Windows

1. PC 安装 Sunshine 
> https://github.com/LizardByte/Sunshine

1. PC 上安装虚拟屏幕工具,我用的是 ParsecVDisplay
> https://github.com/nomi-san/parsec-vdd

1. 平板上安装 moonlight
> https://github.com/LizardByte/awesome-sunshine?tab=readme-ov-file

1. 使用 ParsecVDisplay 创建一个虚拟屏幕

1. 使用平台上的 moonlight 连接一次 pc 端,然后在 Sunshine 的 故障排除|日志 中找到虚拟屏幕的 device_id

1. 将 device_id 填写到 Sunshine | 配置 | Andoi/Video | 输出名称 中

1. 点击 Sunshine 保存 | 应用

1. 平板中再次连接 PC 进行串流

macOS

服务端安装,客户端看 pc 部分


1 安装虚拟屏幕工具
https://github.com/Stengo/DeskPad
brew install deskpad.

2 安装 sunshine-beta
https://app.lizardbyte.dev/?lng=zh-CN

2.1 设置 homebrew 源
brew tap LizardByte/homebrew

2.2 安装
brew install sunshine-beta

2.3 启动
brew services start lizardbyte/homebrew/sunshine-beta

2.4 访问地址
https://localhost:47990

2.5 故障排除|日志 查看虚拟显示器编号
记得刷新一下,不然显示不了最新的日志
找到  Info: Detected display: DeskPad Display (id: 10) connected: true
将 id  10 填写到 配置|Video | 显示 ID 中
重启一下 sunshine (可在故障排除中重启)

3 屏幕管理工具(带虚拟屏幕功能, 还没有试过,备选)
https://github.com/waydabber/BetterDisplay

4 这里其他人安装流程(有虚拟声卡安装)
brew install blackhole-2ch
https://www.bilibili.com/opus/994861442511405058

自动化配置+启动脚本


param(
    [string]$SunshineLogPath = "$HOME/.config/sunshine/sunshine.log",
    [string]$SunshineConfPath = "$HOME/.config/sunshine/sunshine.conf"
)

# --- 脚本功能说明 ---
# 该脚本用于在 macOS 上自动检测 Sunshine 服务的新显示器 ID,
# 并更新 Sunshine 的配置文件以推流到该显示器。
# 脚本步骤包括:
# 1. 重启 Sunshine 服务以触发显示器检测并生成日志。
# 2. 从日志文件中提取最新的显示器 ID。
# 3. 更新配置文件中的 output_name 设置为新的显示器 ID。
# 4. 再次重启 Sunshine 服务以应用新的配置。

$ErrorActionPreference = "Stop"

function showLogs {
    param (
        [string]$message
    )

    Write-Host $message -ForegroundColor Yellow
}

function showErrorLogs {
    param (
        [string]$message
    )

    Write-Host $message -ForegroundColor Red
}

showLogs '重启 Sunshine 以检测新显示器 ID 并更新配置文件...'

brew services stop lizardbyte/homebrew/sunshine-beta
Start-Sleep -Seconds 3

brew services start lizardbyte/homebrew/sunshine-beta
Start-Sleep -Seconds 5

if (-not $?) {
    showErrorLogs 'Sunshine 服务重启失败,脚本终止。'
    exit 1
}

showLogs '重启完成,开始解析日志文件...'

$info = & cat $SunshineLogPath | grep 'Detected display' | grep 'DeskPad' | grep id:
$displayId = $info | Select-Object -Last 1 | Select-String '(?<=id: )\d+' | ForEach-Object { $_.Matches[0].Value } -ErrorAction SilentlyContinue

if (-not $displayId) {
    showErrorLogs '未能从日志中提取到显示器 ID,脚本终止。'
    exit 1
}

showLogs "成功提取到显示器 ID: $displayId"

showLogs '开始更新配置文件...'

$oldName = cat $SunshineConfPath | grep output_name 
$newName = "`noutput_name = $displayId`n"

if ($oldName) {
    showLogs "找到旧的 output_name 配置: $oldName,正在替换..."
    # 读出 $SunshineConfPath 中的内容,然后规则 替换 output_name 行为 $newName ,最后写回文件

    $content = Get-Content -Path $SunshineConfPath -Raw

    $newContent = $content -replace $oldName, $newName

    Set-Content -Path $SunshineConfPath -Value $newContent -Encoding UTF8

}
else {
    showLogs "未找到旧的 output_name 配置,正在添加新的配置..."
    $newName >> $SunshineConfPath
}

showLogs '配置文件更新完成。'

showLogs '再次重启 Sunshine 以应用新配置...'

brew services stop lizardbyte/homebrew/sunshine-beta
Start-Sleep -Seconds 3

brew services start lizardbyte/homebrew/sunshine-beta
Start-Sleep -Seconds 5

if (-not $?) {
    showErrorLogs 'Sunshine 服务重启失败,脚本终止。'
    exit 1
}

Start-Process 'open' 'https://localhost:47990/'

showLogs "处理完成"
上一篇
下一篇