diff --git a/README.en.md b/README.en.md index bf7aace..ac5992e 100644 --- a/README.en.md +++ b/README.en.md @@ -75,6 +75,8 @@ Wayland limits: single screen, fixed resolution. The native Hyprland backend now dynamic resolution yet; the clipboard syncs while the viewer's remote window has focus. On the first connection the desktop asks for "Remote Desktop / Screen Sharing" permission; the permission is remembered once granted. +The native Wayland backend needs `wlr-output-power-management` from the compositor to wake a turned-off screen; without it only wake is unavailable — capture and encoding are unaffected. + Native Wayland experiments: `UU_WAYLAND_PIPELINE=0` disables pipelining for comparison. `UU_WAYLAND_DMABUF=1` explicitly tries dma-buf → GBM CPU mapping (off by default; requires runtime libgbm; `UU_WAYLAND_DMABUF_DEVICE` overrides `/dev/dri/renderD128`). @@ -260,6 +262,8 @@ Common environment variables: Host settings such as "lock after remote session" and "mute host" are stored in `~/.config/uuremote/host_settings.json`. +With external FFmpeg CPU encoding, the bitrate presets (Original / Ultra / HD / custom) use average bitrate (ABR) to avoid gray keyframes at 4K and low bitrates; Auto keeps constant rate factor (CRF). + ## Let an AI agent install or develop it If you use Claude Code, Codex, Cursor or a similar coding agent, have it read [AGENTS.md](AGENTS.md) first. diff --git a/README.md b/README.md index 53cfdb7..5c3fbbf 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ Portal 仅作用于本服务获授权的会话。文件传输、终端等独立 Wayland 下的限制:只支持单屏、固定分辨率;Hyprland 原生后端默认使用双缓冲流水线 shm screencopy,控制端帧率设置会同步到采集节拍和编码器,但实际帧率仍受合成器、渲染和读回速度限制(旧串行路径在 2560x1600 曾测得约 16~22 帧;流水线只在虚拟机里测量过,不代表实机保证);portal 后端暂不支持唤醒屏幕和动态分辨率;剪贴板只在控制端的远控窗口处于前台时同步。 +原生 Wayland 后端需要合成器提供 `wlr-output-power-management` 才能唤醒已关闭的屏幕;缺少该协议不影响采集和编码。 + 原生 Wayland 实验选项:`UU_WAYLAND_PIPELINE=0` 可关闭流水线做对照。`UU_WAYLAND_DMABUF=1` 显式尝试 dma-buf→GBM CPU 映射(默认关闭,需要运行时 libgbm;可用 `UU_WAYLAND_DMABUF_DEVICE` 指定 render node,默认 `/dev/dri/renderD128`)。仅支持显式线性修饰符、单平面 8-bit RGB,失败回退 SHM;virgl VM 中只验证了回退,成功导入/映射和硬件加速均未验证。这不是零拷贝 VAAPI 路径;选择 `UU_VIDEO_ENCODER=vaapi` 时仍由 FFmpeg 上传 CPU 帧。 首次连接时,桌面会弹窗请求「远程桌面 / 屏幕共享」授权,同意后会记住授权。 @@ -231,6 +233,8 @@ systemctl --user restart uuremote-native.service 「远程结束后自动锁屏」「静音运行」等设置保存在 `~/.config/uuremote/host_settings.json`。 +选择码率档(原画 / 超清 / 高清 / 自定义)时,外部 FFmpeg 的 CPU 编码以平均码率(ABR)为目标,避免 4K 低码率下关键帧发灰;「自动」档仍使用恒定质量(CRF)。 + ## 让 AI 帮你安装或开发 如果你用 Claude Code、Codex、Cursor 等 AI 编程工具,让它先阅读 [AGENTS.md](AGENTS.md)。 diff --git a/c_engine/wayland_engine.c b/c_engine/wayland_engine.c index b3a32a8..41c48df 100644 --- a/c_engine/wayland_engine.c +++ b/c_engine/wayland_engine.c @@ -347,6 +347,8 @@ end: } int uu_wl_wake(void) { pthread_mutex_lock(&lock); int result=-1; + /* Output power management is optional; missing it must not block screencopy. */ + if(initialized && !power) result=0; if(initialized && power && !power_failed) { zwlr_output_power_v1_set_mode(power,ZWLR_OUTPUT_POWER_V1_MODE_ON); if(sync_display()==0 && !power_failed) result=0; diff --git a/src/video.rs b/src/video.rs index 7f7f7ca..93527a3 100644 --- a/src/video.rs +++ b/src/video.rs @@ -157,10 +157,13 @@ fn encoder_options(settings: &VideoSettings, encoder: Encoder, gop: &str) -> Vec } if settings.codec == VideoCodec::H265 { return cpu_hevc_options(settings, gop); } let params = format!("aud=1:repeat-headers=1:scenecut=0:keyint={gop}:min-keyint={gop}"); - ["-c:v", "libx264", "-preset", "superfast", "-tune", "zerolatency", + let mut options = vec!["-c:v", "libx264", "-preset", "superfast", "-tune", "zerolatency", "-profile:v", profile, "-pix_fmt", pix_fmt, "-g", gop, "-threads", "4", - "-crf", &cq, "-maxrate", &maxrate, "-bufsize", &bufsize, "-x264-params", ¶ms] - .into_iter().map(str::to_owned).collect() + "-maxrate", &maxrate, "-bufsize", &bufsize, "-x264-params", ¶ms]; + // Capped CRF starves repeated 4K keyframes; use ABR for bitrate presets. + if settings.max_kbps().is_some() { options.extend(["-b:v", &target]); } + else { options.extend(["-crf", &cq]); } + options.into_iter().map(str::to_owned).collect() } fn ffmpeg_command() -> Command {