Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix(capture): enumerate all formats and persist complete capture settings

Veyra Goal Agentb60830c9d97e
diff --git a/AGENTS.md b/AGENTS.md
index 453c444e..c4c05164 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra 项目 Agent 执行规则
+> **2026-10-12 PR34 合并与采集设置授权**:用户明确合并 PR34、补齐当前卡全部设备格式及采集页自动保存/继续上次/启动自动恢复。按 docs/PR34_CAPTURE_SETTINGS_PLAN_2026-10-12.md 从 main76f41b3 在 codex/pr34-capture-settings-20261012 隔离适配必要 source/bridge/QML/preferences/测试接点,覆盖这些范围旧冻结。构建及定向验收后允许 main 合并与普通推送以完成 GitHub PR 合并。62 旧树/509 脏文件保持,main仅按授权更新;其它尚未合并分支不混入。保持 UI33ms/250ms、默认优先级与正常采集缓冲,不派Agent、不改驱动/运行库/真实配置。全产物E盘,测试≤300秒/构建≤900秒,无打包/Release/关机。
+
> **2026-10-11 当前修复已合入本地main**:Codex4557ab6(含e8300d9)与Claude1d4c33f经隔离整合、42依赖闭包/13EXE构建、完整CMake、16组回归、12真实GUI状态/6布局及SR+VFG组合持久化/重启通过;实测产品4904b73、记录tip adcf509通过功能merge d2e1396进入main,完整Git树相同。VFG默认中档、DLSS K、33ms统计/250ms状态及负优化撤回保持。59开工树中唯main按授权更新,其余58树/504脏文件、来源分支及原包1626文件保持;final.json见reports/merge-current-fixes-20261011。首次组合GUI夹具漏FG节点失败,修夹具后通过,原证据保留;没有新的性能A/B或全硬件/长期显存通过声明。无push/打包/Release/关机。
> **2026-10-11 当前修复本地合并授权**:用户明确要求将 Codex 与 Claude 当前修复合入 main。按 docs/MERGE_CURRENT_FIXES_PLAN_2026-10-11.md,在 codex/merge-current-fixes-20261011 整合已验4557ab6(含e8300d9)与Claude1d4c33f,必要冲突适配后构建/定向回归,再本地main合并;覆盖这些接点历史no-merge。59旧工作树/504脏文件及来源tip由独立start/bundle保护,main仅按本次授权更新。默认档位、33ms统计/250ms状态节奏保持,不派Agent,不改运行库/模型/驱动/真实配置。产物全E盘,每测试≤300秒、构建≤900秒;不push/Release/打包/关机,不恢复已撤回负优化或旧未完成实验。
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c74a6c8d..b6334d74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -733,6 +733,8 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
add_executable(veyra_capture_format_selection_tests tests/unit/CaptureFormatSelectionTests.cpp)
target_compile_features(veyra_capture_format_selection_tests PRIVATE cxx_std_20)
target_include_directories(veyra_capture_format_selection_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+ target_compile_definitions(veyra_capture_format_selection_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
+ target_link_libraries(veyra_capture_format_selection_tests PRIVATE ole32 strmiids)
add_executable(veyra_presentation_worker_tests tests/unit/LiveGpuSchedulerTests.cpp)
target_compile_features(veyra_presentation_worker_tests PRIVATE cxx_std_20)
target_compile_definitions(veyra_presentation_worker_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
diff --git a/docs/PR34_CAPTURE_SETTINGS_PLAN_2026-10-12.md b/docs/PR34_CAPTURE_SETTINGS_PLAN_2026-10-12.md
new file mode 100644
index 00000000..35d55ad7
--- /dev/null
+++ b/docs/PR34_CAPTURE_SETTINGS_PLAN_2026-10-12.md
@@ -0,0 +1,14 @@
+# PR34 采集格式与设置恢复
+
+用户授权合并 PR34,并补齐当前设备全部格式、采集页修改自动保存、继续上次及启动自动恢复。
+
+基线本地 main 76f41b3,远端 main 4ceb2df,PR 原提交 f1f53ace。隔离分支 codex/pr34-capture-settings-20261012,保留作者提交与已验主线修复,不混入尚未合并的 XeSS 实验。62 个既有工作树、509 个未提交文件由 E:/项目/Veyra/archives/pr34-capture-settings-20261012/start.json 保护;唯一 main 按本次授权推进。
+
+## 实现与验证
+
+- 保留分辨率、帧率、像素格式联动,枚举驱动媒体类型及公开的离散帧率,不使用固定分辨率或帧率白名单,不虚构设备组合。设备上报但播放器不能接入的格式仍列明限制,禁止悄悄替换。
+- 适配 DeckLink 自动模式、扫描类型、旧格式键、驱动属性页回选及查询结果过期;不新增采集缓冲、像素回读、GPU 等待或持续 UI 绘制。
+- 设备/格式/音频/帧率/色彩即时保存,翻转、SDR、音频模式及缓冲作为跨编辑模式的全局设置恢复。继续上次与启动自动进入使用同一恢复路径,缺失设备/格式/音频不得静默换成另一输入。
+- 构建实际 Windows 产品及相关格式、偏好、采集/DeckLink测试;私有配置中实际 GUI 修改、未连接退出、重启、继续上次及自动恢复。无相应实卡的部分明确列为未验。
+
+全产物 E:/项目/Veyra 的本任务 build/tests/logs/tmp/reports/archives 目录。保持 33ms 统计及约 250ms 状态节奏、GPU 默认优先级、NR/SR/补帧算法和运行库原件。不派子 Agent,不修改用户真实配置。不打包、不发 Release、不关机;验证后完成 PR34 和必要适配的 main 合并/普通推送,不强推。
diff --git a/docs/PR34_CAPTURE_SETTINGS_REPORT_2026-10-12.md b/docs/PR34_CAPTURE_SETTINGS_REPORT_2026-10-12.md
new file mode 100644
index 00000000..65445a2a
--- /dev/null
+++ b/docs/PR34_CAPTURE_SETTINGS_REPORT_2026-10-12.md
@@ -0,0 +1,41 @@
+# PR34 采集格式与设置恢复验收
+
+本轮接入 [PR34](https://github.com/Likely7/Veyra-NRVideo/pull/34),保留作者 f1f53ace 的三个联动选择框和提交历史,在本地已验 main 76f41b3 上补齐格式枚举与设置持久化。隔离分支 `codex/pr34-capture-settings-20261012`,原始整合提交 d67417fe。GitHub 合并及最终 main 提交单独记录在本报告收尾和 `E:/项目/Veyra/reports/pr34-capture-settings-20261012/final.json`。
+
+## 解决的缺口
+
+- 旧枚举只读取 `IAMStreamConfig::GetStreamCaps` 每条能力记录中的默认帧间隔,另外还过滤了大于 3840×2160 的条目。现在结合驱动公开的 `IAMVideoControl::GetFrameRateList` 展开离散帧率,保留原始媒体类型索引、扫描类型和精确 100ns 间隔;不根据 min/max 范围虚构常用帧率,不使用固定分辨率表。未提供该可选接口的驱动继续使用它上报的原始类型。
+- 分辨率、帧率、像素格式只组合设备实际报告的媒体类型。相同数字的逐行/隔行模式、不同字段顺序与同名像素格式保留独立身份。旧格式键只有唯一匹配时迁移,不能唯一确定时要求重新选择。连接时使用所选精确帧间隔;设备帧率填 0 不会退回能力记录的另一帧率。
+- 超出播放器接入能力的尺寸/已知原始像素布局仍显示,但标为不支持、禁止连接;列出能力不代表新增 8K 播放承诺。BMD 自动模式显示“自动检测实际信号/跟随实际信号/自动选择像素格式”,不再显示 0×0 或 0fps。原生模式列表保留卡上报的全部制式,自动初始化只选播放器可接入的尺寸。
+- 设备、所选媒体类型、显式音频输入、设备帧率、色彩/范围均在修改时保存,不再依赖“连接并开始”。翻转、转 SDR、设备缓冲和音频入口模式作为跨列表/节点模式的全局设置保存,并在启动自动恢复之前还原。既有 Blackmagic/美乐威偏好保留。
+- “继续上次”和启动自动恢复共用恢复路径,使用最新保存的表单。缺失设备、媒体类型或音频端点时保留原记录并提示,不静默换卡、换格式或改成静音。另修复失效格式没有活动选择时,修改其他控件会清空旧格式键的边界情况。
+- 设置文件使用 `QSaveFile` 原子替换;保存失败会提示。连续刷新/切换设备只保留最新待查询请求,避免旧异步结果覆盖最终选择。原有 33ms 统计、约 250ms 状态更新、默认 GPU 优先级、采集队列/缓冲及逐帧处理保持。
+- 相对 main 增加 42 个完整的繁中/英文/日文翻译键。消除 PR 与 main 自动合并产生的“逐行”重复键,保留 main 原值和两个旧采集标签;既有翻译值没有被覆盖。
+
+## 本机证据
+
+所有命令使用本机 Python 3.11,`-X utf8 -B -I`;所有私有 profile、TEMP/TMP、缓存和产物均在 `E:/项目/Veyra/`。没有使用用户真实配置,也没有修改已发布包或运行库原件。
+
+| 检查 | 结果与边界 |
+| --- | --- |
+| 产品构建 | `tmp/pr34-capture-settings-20261012/build.py`,基于已验 main 依赖对象,7 个依赖闭包对象及必要 MOC、DeckLink SDK ABI、资源/Shader 接点,链接 GUI 和相关测试共 12 个 EXE;不是全量从零编译。最终构建 12.1 秒,receipt 在 `logs/pr34-capture-settings-20261012/build-20261012-143029/receipt.json`。|
+| 完整 CMake 配置 | `configure.py` 通过;确认离散帧率测试的 COM 库、DeckLink 及 RemotePlay/Moonlight/Xbox 配置均保留,没有 QuickPrivate 或整窗重绘接点。日志 `configure-20261012-141411`。|
+| 11 组定向回归 | `harness/regress.py capture-formats decklink capture-color ui-contracts contracts chain library presets slider menu components` 全通过;最终 `pr34/tests-20261012-143150/receipt.json`,单项最长 9.2 秒。包括旧键迁移、非标准分辨率、离散帧率、隔行、重复像素类型、BMD 自动制式/超尺寸拒绝及既有控件/设置契约。|
+| 完整格式可达性 | 本机 MCS 4K-T911 驱动返回 96 条能力记录,展开并按精确媒体身份去重后为 9 种分辨率、378 个组合。实际 GUI 遍历三个选择框可到达全部 378 个键,没有添加不存在的组合。原始记录 `reports/pr34-capture-settings-20261012/capture-enumerated.json`。这只是该卡的驱动报告,不代表每种输入信号都实测。|
+| 未连接即保存 | 实际 GUI 修改格式、FPS、音频、色彩及四个全局控件,未连接就退出;重启检查可见控件与真实 bridge 一致。之后建立实际会话,再修改而不连接,新设置仍供下一次继续/自动恢复使用。|
+| 实卡恢复 | 本机 MCS 4K-T911 的 1080p30 NV12 连接、手动继续、启动自动恢复均通过,实际返回帧流约 30fps。既测设备 FPS=0 使用所选离散 30fps,也测显式 FPS=30。新草稿中的 flip=false、SDR=false、缓冲=驱动默认、音频入口=位流优先等准确恢复;本次音频输入显式关闭,未声称验证了实际 Dolby/DTS 输入。|
+| 最终 GUI | `harness/final-ui.py`:四语言布局、列表/节点切换后全局值、连续刷新/设备切换、手动继续、连接、自动恢复、缺失格式/音频/设备共 9 组全通过。日志 `ui-*-20261012-143224` 至 `143320`;所有 GUI receipt 的生产 Main.qml 恢复检查为 true。|
+| 写入后缺失记录保留 | 在私有 profile 模拟缺失格式/音频/设备;拒绝静默连接。修改其他参数后检查磁盘文件,原缺失标识仍在。不是只检查界面上的临时值。|
+| 翻译与源码审查 | `scripts/i18n/extract.py --check` 占位符错误 0;剩余 6 条未译属于既有 HDR/导出文本。`git diff --check` 通过;新增源码没有 DLL、SDK、模型或媒体文件。|
+
+最终 GUI SHA256:`5dc08c327c052ab139394c89e0f206676162da84f62b4076a4c753878ab711de`。验证程序是私有验收目录中的 EXE,本轮没有生成便携测试包或 Release。
+
+## 失败、修正与未验范围
+
+两次早期 GUI 夹具失败均保留原日志:`ui-edit-20261012-141307` 在关闭时脱离可视树的对话框上查找对象失败;`141332` 错把没有运行来源时的待应用配置当作必须等待的播放事务,85 秒自动退出而没有 PASS。只修私有夹具:从 Main.qml 的实际 dialogs 引用打开,空闲表单检查不等待运行中的帧事务。后续未连接保存和最终 9 组真实 GUI 全通过,生产程序没有加入测试 Timer/Loader。私有 profile 准备脚本首次按带 BOM 的 UTF-16 读取无 BOM 文件失败,改为产品实际 UTF-16LE;未改产品文件格式。自动合并工作树创建尚未结束时,提前执行的 merge 被 index.lock 拒绝;等待创建完成后正常合并,没有手工删除锁或重置既有目录。
+
+对抗式审查发现并修掉了失效格式键被其他控件保存清空的问题,以及 PR/main 翻译重复键。保留审查断言失败及最终复核结果;不以第一次编译通过替代验收。
+
+本机没有 BMD/美乐威实卡,因此原生自动识别、HDMI/SDI 输入切换、各卡所有格式的真实出画仍需对应持卡用户验证。本轮验证了枚举、参数恢复、错误处理和本机 USB 采集连接,没有做跨显卡、长时间、端到端延迟或性能提升承诺。驱动未公开的私有格式与连续能力区间无法凭空枚举为有限列表;界面列出的是驱动公开的离散能力。
+
+开工 62 个既有工作树、509 个脏文件由独立 `archives/pr34-capture-settings-20261012/start.json` 和增量 bundle 保护;除获授权的 main 外保持原样。未混入尚未合并的 XeSS 接手分支。最终源码、二进制、原包 1626 文件、合并 ancestry 与远端状态由 `reports/pr34-capture-settings-20261012/validation.json`/`final.json` 记录。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index dbf9be5c..4beb96ee 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9155,3 +9155,15 @@ seal.py validate逐项核对源码/输入/EXE/QML/原包1626文件及旧树;
2026-10-11 本地合并收尾:实测产品4904b73,补报告/WORKLOG后tip adcf509;main功能merge d2e1396无冲突,完整Git树与adcf509相同。后续仅四份收尾文档。seal.py final核对833源码/配置、13EXE、所有回执及来源祖先、main clean、其它58旧树/504脏文件和原包1626文件,最终main提交/增量bundle/标签见reports/merge-current-fixes-20261011/final.json。本轮无推送/打包/发布/关机,来源分支均保留,不把原正式/测试包说成已经更新。
首次final raw-SHA核对停止于旧main ColorDetailPass.h;逐项排查只有9个旧文件LF/CRLF差异,去除CRLF后字节完全相同,Git树仍仅四份文档差异。保留final-raw-hash-attempt.json,核对器改为对这类差异额外验证唯一换行转换及完整Git内容,并记录两份checkout SHA;未改任何产品/旧源文件。后续final.json记录最终通过结果。
+
+## 2026-10-12 PR34 全格式与采集设置恢复
+
+用户授权合并 PR34、补齐当前卡全部公开格式、采集页全部设置自动保存及继续/启动自动恢复。main76f41b3 起点,隔离 codex/pr34-capture-settings-20261012;作者 f1f53ace 完整合入 d67417fe,保留最新已验主线,未合未验 XeSS 分支。开工 62 旧工作树/509 脏文件独立 start.json 与增量 source-before.bundle 已核验。创建工作树尚未结束时一次提前 merge 被 index.lock 拒绝,等待完成后正常整合,没有删锁、reset 或覆盖旧目录。
+
+增加 IAMVideoControl GetFrameRateList 离散帧率枚举及精确 100ns 类型选择、完整尺寸列表与不能接入的格式标注,补 BMD 自动模式和 4K 接入边界;修改即保存设备/格式/音频/FPS/色彩,启动恢复 flip/SDR/buffer/audio ingress。QSaveFile 原子保存;缺失卡/音频/格式保留记录,其他控件不得清空失效格式键;异步查询保留最新请求。UI33ms/250ms、默认优先级、正常逐帧链路和缓冲不变。保留 main 全部翻译值,新增42完整三语言键并消除PR合并产生的“逐行”重复项。
+
+实际命令 python -X utf8 -B -I E:/项目/Veyra/tmp/pr34-capture-settings-20261012/build.py:7依赖闭包对象/12EXE定向构建,最终12.1秒,非从零全量重编。configure.py完整CMake通过。harness/regress.py capture-formats decklink capture-color ui-contracts contracts chain library presets slider menu components 共11项最终全通过,logs/pr34-capture-settings-20261012/pr34/tests-20261012-143150;最长9.2秒。本机MCS 4K-T911 驱动96能力记录展开378媒体组合/9分辨率,真实GUI三选择框全部可达;1080p30 NV12 连接、FPS=0离散30档、显式FPS30、手动继续/启动自动恢复通过。设备并未逐格式实测,未测实际音频位流。
+
+harness/final-ui.py最终9组通过:四语言布局、跨列表/节点全局保持、查询排队、手动继续/连接/自动恢复、缺失格式/音频/设备及磁盘记录保留;日志ui-*-20261012-143224至143320。另测未连接修改直接退出,以及建立会话后修改新草稿再重启恢复。GUI SHA5dc08c327c052ab139394c89e0f206676162da84f62b4076a4c753878ab711de。早期两次私有GUI夹具失败(脱离树查找/空闲事务等待)、UTF-16 BOM误判和审查断言均保留;只修夹具或确实存在的产品缺口,生产Main恢复,未加测试Timer或持续绘制。i18n --check占位符0错误,既有HDR/导出6条未译保留,diff --check通过。
+
+全部源码以外产物在E:/项目/Veyra本轮build/tests/logs/tmp/reports/archives目录,私有profile和子进程缓存。源/二进制及原包1626文件、旧树保持校验见validation.json,Git收尾见final.json。BMD/美乐威没有实卡,真实出画和全制式待持卡用户确认;不宣称性能提升、全硬件或长期稳定通过。详细记录docs/PR34_CAPTURE_SETTINGS_REPORT_2026-10-12.md。验证后合入并普通推送main完成PR34,无打包/Release/关机。
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 50ba9182..482a8e71 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -12647,7 +12647,7 @@
{
"zh": "逐行",
"src": "src/source/CaptureCardSource.cpp",
- "zh-TW": "逐行",
+ "zh-TW": "循序",
"en": "Progressive",
"ja": "プログレッシブ"
},
@@ -15108,13 +15108,6 @@
"en": "This BMD card does not support automatic detection. Select the manual format matching the signal.",
"ja": "この BMD カードは自動検出に対応していません。信号に一致する手動形式を選んでください。"
},
- {
- "zh": "逐行",
- "src": "src/source/CaptureCardSource.cpp",
- "zh-TW": "循序",
- "en": "Progressive",
- "ja": "プログレッシブ"
- },
{
"zh": "隔行",
"src": "src/source/CaptureCardSource.cpp",
@@ -15331,6 +15324,251 @@
"zh-TW": "VFG 中間影格約 %1 ms、其餘每張約 %2 ms,目前負載約可穩定 %3X",
"en": "VFG takes about %1 ms for the middle frame and %2 ms for each other frame; about %3X holds at the current load",
"ja": "VFG は中央の 1 枚が約 %1 ms、その他は 1 枚あたり約 %2 ms、現在の負荷で安定するのは約 %3X"
+ },
+ {
+ "zh": "自动检测实际信号",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": "自動偵測實際訊號",
+ "en": "Detect the input signal automatically",
+ "ja": "入力信号を自動検出"
+ },
+ {
+ "zh": "跟随实际信号",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": "跟隨實際訊號",
+ "en": "Follow the input signal",
+ "ja": "入力信号に合わせる"
+ },
+ {
+ "zh": "设备默认帧率",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": "裝置預設幀率",
+ "en": "Device default frame rate",
+ "ja": "デバイスの既定フレームレート"
+ },
+ {
+ "zh": " · 驱动默认",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": " · 驅動預設",
+ "en": " · Driver default",
+ "ja": " · ドライバーの既定値"
+ },
+ {
+ "zh": " · 当前播放器不支持",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": " · 目前播放器不支援",
+ "en": " · Unsupported by this player",
+ "ja": " · このプレイヤーでは非対応"
+ },
+ {
+ "zh": "当前播放器不支持",
+ "src": "include/veyra/source/CaptureFormatSelection.h",
+ "zh-TW": "目前播放器不支援",
+ "en": "Unsupported by this player",
+ "ja": "このプレイヤーでは非対応"
+ },
+ {
+ "zh": "自动选择像素格式",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "自動選擇像素格式",
+ "en": "Automatic pixel format",
+ "ja": "ピクセルフォーマットを自動選択"
+ },
+ {
+ "zh": "设备提供此格式,但当前播放器不支持其尺寸或像素布局,请选择其他格式",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "裝置提供此格式,但目前播放器不支援其尺寸或像素配置,請選擇其他格式",
+ "en": "The device offers this format, but this player cannot handle its size or pixel layout. Choose another format",
+ "ja": "デバイスはこの形式を提供していますが、このプレイヤーではサイズまたはピクセル配置に対応していません。別の形式を選んでください"
+ },
+ {
+ "zh": "设备提供此制式,但当前播放器的 BMD 采集最高支持 3840×2160",
+ "src": "src/source/DeckLinkCapture.cpp",
+ "zh-TW": "裝置提供此制式,但目前播放器的 BMD 擷取最高支援 3840×2160",
+ "en": "The device offers this mode, but BMD capture in this player supports up to 3840×2160",
+ "ja": "デバイスはこのモードを提供していますが、このプレイヤーの BMD キャプチャは最大 3840×2160 です"
+ },
+ {
+ "zh": "采集设置保存失败,请检查配置目录是否可写",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "擷取設定儲存失敗,請檢查設定目錄是否可寫入",
+ "en": "Could not save capture settings. Check that the configuration folder is writable",
+ "ja": "キャプチャ設定を保存できません。設定フォルダーに書き込めるか確認してください"
+ },
+ {
+ "zh": "上次的音频输入未连接",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "上次的音訊輸入未連接",
+ "en": "Previous audio input is disconnected",
+ "ja": "前回の音声入力が接続されていません"
+ },
+ {
+ "zh": "上次的音频输入未连接,请插回设备或重新选择音频监听",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "上次的音訊輸入未連接,請重新插入裝置或選擇音訊監聽",
+ "en": "The previous audio input is disconnected. Reconnect it or select an audio input",
+ "ja": "前回の音声入力が接続されていません。再接続するか音声入力を選び直してください"
+ },
+ {
+ "zh": "未读到设备上报的采集格式,或设备正被其他应用占用。",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "未讀到裝置回報的擷取格式,或裝置正被其他應用程式佔用。",
+ "en": "No capture formats were reported, or the device is in use by another application.",
+ "ja": "キャプチャ形式が取得できないか、他のアプリがデバイスを使用しています。"
+ },
+ {
+ "zh": "BMD 驱动返回的连接格式与所选模式不同,请按实际信号重新选择格式。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "BMD 驅動回傳的連接格式與所選模式不同,請依實際訊號重新選擇格式。",
+ "en": "The BMD driver connected with a different format. Select a format that matches the input signal.",
+ "ja": "BMD ドライバーが選択したモードと異なる形式で接続しました。実際の信号に合う形式を選び直してください。"
+ },
+ {
+ "zh": "先断开采集,再配置驱动",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "先中斷擷取,再設定驅動",
+ "en": "Disconnect capture before configuring the driver",
+ "ja": "キャプチャを切断してからドライバーを設定"
+ },
+ {
+ "zh": "收到黑帧 · 检查输入制式",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "收到黑幀 · 檢查輸入制式",
+ "en": "Black frames received · Check the input mode",
+ "ja": "黒いフレームを受信 · 入力モードを確認"
+ },
+ {
+ "zh": "无法打开驱动设置;请先断开采集并关闭占用设备的应用。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "無法開啟驅動設定;請先中斷擷取並關閉佔用裝置的應用程式。",
+ "en": "Cannot open driver settings. Disconnect capture and close applications using the device first.",
+ "ja": "ドライバー設定を開けません。キャプチャを切断し、デバイスを使用中のアプリを閉じてください。"
+ },
+ {
+ "zh": "正在收帧",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "正在接收影格",
+ "en": "Receiving frames",
+ "ja": "フレームを受信中"
+ },
+ {
+ "zh": "设备属性",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "裝置屬性",
+ "en": "Device properties",
+ "ja": "デバイスのプロパティ"
+ },
+ {
+ "zh": "设备查询或驱动设置尚未完成",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "裝置查詢或驅動設定尚未完成",
+ "en": "Wait for the device query or driver settings to finish",
+ "ja": "デバイスの検索またはドライバー設定が完了するまでお待ちください"
+ },
+ {
+ "zh": "请先选择设备并等待查询完成",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "請先選擇裝置並等待查詢完成",
+ "en": "Select a device and wait for the query to finish",
+ "ja": "デバイスを選択し、検索が完了するまでお待ちください"
+ },
+ {
+ "zh": "请等待连接结束并断开采集,再打开驱动设置",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "請等待連接完成並中斷擷取,再開啟驅動設定",
+ "en": "Wait for the connection to finish, then disconnect capture before opening driver settings",
+ "ja": "接続が完了してからキャプチャを切断し、ドライバー設定を開いてください"
+ },
+ {
+ "zh": "请选择与输入信号一致的格式。驱动默认格式不代表检测到的信号。",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "請選擇與輸入訊號一致的格式。驅動預設格式不代表偵測到的訊號。",
+ "en": "Choose a format that matches the input signal. The driver default is not a detected signal format.",
+ "ja": "入力信号に合う形式を選んでください。ドライバーの既定値は信号検出の結果ではありません。"
+ },
+ {
+ "zh": "输入选择",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "輸入選擇",
+ "en": "Select input",
+ "ja": "入力を選択"
+ },
+ {
+ "zh": "配置驱动公开的输入与视频属性;其他采集应用占用设备时请先关闭",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "設定驅動提供的輸入與視訊屬性;請先關閉佔用裝置的其他擷取程式",
+ "en": "Configure the input and video properties exposed by the driver. Close other capture applications using the device first.",
+ "ja": "ドライバーが提供する入力と映像のプロパティを設定します。デバイスを使用中の他のキャプチャアプリを先に閉じてください。"
+ },
+ {
+ "zh": "采集卡上游输入连接失败(0x{:08X}),请检查驱动与输入选择。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "擷取卡上游輸入連接失敗(0x{:08X}),請檢查驅動與輸入選擇。",
+ "en": "Capture card upstream input connection failed (0x{:08X}). Check the driver and selected input.",
+ "ja": "キャプチャカードの上流入力への接続に失敗しました(0x{:08X})。ドライバーと入力の選択を確認してください。"
+ },
+ {
+ "zh": "采集视频格式",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "擷取視訊格式",
+ "en": "Capture video format",
+ "ja": "キャプチャ映像形式"
+ },
+ {
+ "zh": "采集设备驱动设置",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "擷取裝置驅動設定",
+ "en": "Capture device driver settings",
+ "ja": "キャプチャデバイスのドライバー設定"
+ },
+ {
+ "zh": "采集输入选择",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "擷取輸入選擇",
+ "en": "Capture input selection",
+ "ja": "キャプチャ入力の選択"
+ },
+ {
+ "zh": "驱动没有公开此设置页。Blackmagic 请用 Desktop Video Setup 选择 HDMI/SDI,并在采集面板匹配分辨率、帧率和逐行/隔行制式。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "驅動未提供此設定頁。Blackmagic 請使用 Desktop Video Setup 選擇 HDMI/SDI,並在擷取面板匹配解析度、幀率及循序/交錯制式。",
+ "en": "The driver does not provide this settings page. For Blackmagic, select HDMI/SDI in Desktop Video Setup and match the resolution, frame rate, and progressive/interlaced mode in the capture panel.",
+ "ja": "ドライバーはこの設定画面を提供していません。Blackmagic は Desktop Video Setup で HDMI/SDI を選び、キャプチャ画面で解像度、フレームレート、プログレッシブ/インターレースを合わせてください。"
+ },
+ {
+ "zh": "驱动设置",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "驅動設定",
+ "en": "Driver settings",
+ "ja": "ドライバー設定"
+ },
+ {
+ "zh": "驱动设置已关闭。请核对所选格式与设备帧率,再连接。",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "驅動設定已關閉。請核對所選格式與裝置幀率,再連接。",
+ "en": "Driver settings are closed. Check the selected format and device frame rate before connecting.",
+ "ja": "ドライバー設定を閉じました。選択した形式とデバイスのフレームレートを確認してから接続してください。"
+ },
+ {
+ "zh": "驱动设置无法打开(0x{:08X})。",
+ "src": "src/source/CaptureCardSource.cpp",
+ "zh-TW": "驅動設定無法開啟(0x{:08X})。",
+ "en": "Cannot open driver settings (0x{:08X}).",
+ "ja": "ドライバー設定を開けません(0x{:08X})。"
+ },
+ {
+ "zh": "设备实际支持的格式",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "裝置實際支援的格式",
+ "en": "Formats the device actually supports",
+ "ja": "デバイスが実際に対応するフォーマット"
+ },
+ {
+ "zh": "请选择格式",
+ "src": "qml/DialogHost.qml",
+ "zh-TW": "請選擇格式",
+ "en": "Choose a format",
+ "ja": "フォーマットを選んでください"
}
]
}
diff --git a/include/veyra/source/CaptureFormatSelection.h b/include/veyra/source/CaptureFormatSelection.h
index 155feac0..2145b8da 100644
--- a/include/veyra/source/CaptureFormatSelection.h
+++ b/include/veyra/source/CaptureFormatSelection.h
@@ -1,6 +1,7 @@
#pragma once
#include "veyra/source/CaptureFrameRate.h"
#include <algorithm>
+#include <cstdint>
#include <format>
#include <span>
#include <vector>
@@ -9,9 +10,9 @@ namespace veyra::source {
// `pixel` / `scan` / `interlaced` describe the same media type as `key`.
// The capture dialog offers them as three linked choices; `key` stays the
// persisted identity so an old combined selection still restores one type.
-struct CaptureFormat {int index=0;unsigned width=0,height=0;double fps=0;std::wstring label;std::wstring key;int rank=0;int tier=0;bool driverCurrent=false;std::wstring pixel;std::wstring scan;bool interlaced=false;};
+struct CaptureFormat {int index=0;unsigned width=0,height=0;double fps=0;std::wstring label;std::wstring key;int rank=0;int tier=0;bool driverCurrent=false;std::wstring pixel;std::wstring scan;bool interlaced=false;int64_t interval100ns=0;bool supported=true;bool automatic=false;};
enum class CaptureFormatAxis { Resolution, FrameRate };
-struct CaptureFormatOption { std::wstring id, label; };
+struct CaptureFormatOption { std::wstring id, label; bool disabled=false; };
inline const CaptureFormat* selectCaptureFormat(std::span<const CaptureFormat> formats,int legacyIndex,std::wstring_view key){
for(const auto& format:formats)
@@ -30,18 +31,23 @@ inline const CaptureFormat* selectCaptureFormat(std::span<const CaptureFormat> f
}
inline std::wstring captureResolutionId(const CaptureFormat& format){
+ if(format.automatic)return L"auto";
return std::format(L"{}x{}",format.width,format.height);
}
inline std::wstring captureFrameRateId(const CaptureFormat& format){
+ if(format.automatic)return L"auto";
// Progressive and interlaced modes that share a numeric rate stay distinct.
// Field order stays on the pixel list, so it does not create two identical fps rows.
- return std::format(L"{:.6f}|{}",format.fps,format.interlaced?1:0);
+ return std::format(L"{}|{}",format.interval100ns>0?format.interval100ns:format.fps>0?captureFrameInterval(format.fps):0,format.interlaced?1:0);
}
inline std::wstring captureResolutionLabel(const CaptureFormat& format){
+ if(format.automatic)return L"自动检测实际信号";
return std::format(L"{} × {}",format.width,format.height);
}
inline std::wstring captureFrameRateLabel(const CaptureFormat& format){
- auto label=std::format(L"{:.2f} fps",format.fps);
+ if(format.automatic)return L"跟随实际信号";
+ if(format.fps<=0)return L"设备默认帧率";
+ auto label=std::format(L"{:.3f} fps",format.fps);
if(!format.scan.empty())label+=L" · "+format.scan;
return label;
}
@@ -52,6 +58,7 @@ inline std::wstring capturePixelLabel(const CaptureFormat& format,bool ambiguous
label+=std::format(L" [format {}]",format.index);
}
if(format.driverCurrent)label+=L" · 驱动默认";
+ if(!format.supported)label+=L" · 当前播放器不支持";
return label;
}
inline std::vector<CaptureFormatOption> captureResolutionOptions(std::span<const CaptureFormat> formats){
@@ -89,7 +96,8 @@ inline std::vector<CaptureFormatOption> capturePixelOptions(std::span<const Capt
for(const auto* format:matched){
int copies=0;
for(const auto* other:matched)if(other->pixel==format->pixel)++copies;
- out.push_back({format->key,capturePixelLabel(*format,copies>1)});
+ if(std::any_of(out.begin(),out.end(),[&](const CaptureFormatOption& option){return option.id==format->key;}))continue;
+ out.push_back({format->key,capturePixelLabel(*format,copies>1),!format->supported});
}
return out;
}
diff --git a/include/veyra/source/CaptureFrameIntervals.h b/include/veyra/source/CaptureFrameIntervals.h
new file mode 100644
index 00000000..8e5bb71d
--- /dev/null
+++ b/include/veyra/source/CaptureFrameIntervals.h
@@ -0,0 +1,23 @@
+#pragma once
+#include <dshow.h>
+#include <algorithm>
+#include <vector>
+
+namespace veyra::source {
+// The driver owns this discrete list. A min/max interval range is not a list
+// of supported standard frame rates; never expand it using a preset table.
+inline std::vector<REFERENCE_TIME> captureFrameIntervals(IAMVideoControl* control, IPin* pin,
+ int index, SIZE dimensions, REFERENCE_TIME advertised, HRESULT* queryResult=nullptr) {
+ std::vector<REFERENCE_TIME> out{advertised};
+ HRESULT hr=E_NOINTERFACE;
+ if(control&&pin){
+ long count=0;LONGLONG* rates=nullptr;
+ hr=control->GetFrameRateList(pin,index,dimensions,&count,&rates);
+ if(SUCCEEDED(hr)&&rates&&count>0&&count<=1000000)
+ for(long i=0;i<count;++i)if(rates[i]>0&&std::find(out.begin(),out.end(),rates[i])==out.end())out.push_back(rates[i]);
+ CoTaskMemFree(rates);
+ }
+ if(queryResult)*queryResult=hr;
+ return out;
+}
+}
diff --git a/qml/Veyra/DialogHost.qml b/qml/Veyra/DialogHost.qml
index 3d572364..ecff09bc 100644
--- a/qml/Veyra/DialogHost.qml
+++ b/qml/Veyra/DialogHost.qml
@@ -450,6 +450,7 @@ Item {
VRow {
label: qsTr("Dolby / DTS 位流")
VSeg {
+ objectName: "capture-audio-ingress"
options: [{ id: "0", label: qsTr("自动") }, { id: "1", label: qsTr("强制 PCM") }, { id: "2", label: qsTr("位流优先") }]
current: String(veyra.captureAudioIngress)
onPicked: id => veyra.captureAudioIngress = Number(id)
@@ -462,6 +463,7 @@ Item {
label: qsTr("输入色彩(SDR / HDR)")
hint: qsTr("不确定就选「自动」。采集 HDR:采集格式选 P010,这里选「HDR · PQ」(游戏机、显卡的 HDR10 都是 PQ)。「HDR · HLG」用于广播信号。「SDR · 709」是普通画面。变更需重连")
VSeg {
+ objectName: "capture-color-space"
options: [{ id: "0", label: qsTr("自动") }, { id: "1", label: "HDR · PQ" }, { id: "2", label: "HDR · HLG" }, { id: "3", label: "SDR · 709" }]
current: String(veyra.captureColorSpace)
onPicked: id => veyra.captureColorSpace = Number(id)
@@ -471,6 +473,7 @@ Item {
label: qsTr("输入范围")
hint: qsTr("Limited = 16–235,Full = 0–255。画面发灰选「有限」,暗部全黑、亮部过曝选「完全」")
VSeg {
+ objectName: "capture-color-range"
options: [{ id: "0", label: qsTr("自动") }, { id: "1", label: qsTr("有限 · Limited") }, { id: "2", label: qsTr("完全 · Full") }]
current: String(veyra.captureColorRange)
onPicked: id => veyra.captureColorRange = Number(id)
@@ -480,6 +483,7 @@ Item {
label: qsTr("设备缓冲")
hint: qsTr("自动:1080p 及以下 2 帧,更高 3 帧;最小 1 帧延迟最低但可能丢帧")
VSeg {
+ objectName: "capture-buffer-mode"
options: [{ id: "0", label: qsTr("自动") }, { id: "1", label: qsTr("最小") }, { id: "2", label: qsTr("驱动默认") }]
current: String(veyra.captureBufferMode)
onPicked: id => veyra.captureBufferMode = Number(id)
@@ -489,6 +493,7 @@ Item {
label: qsTr("转为 SDR 显示")
hint: qsTr("收到 HDR 也按 SDR 预览,立即生效")
VSwitch {
+ objectName: "capture-force-sdr"
checked: veyra.captureForceSdr
onToggled: checked => veyra.captureForceSdr = checked
}
@@ -497,6 +502,7 @@ Item {
label: qsTr("画面上下翻转")
hint: qsTr("采集画面倒置时开启,立即生效")
VSwitch {
+ objectName: "capture-flip-vertical"
checked: veyra.captureFlipVertical
onToggled: checked => veyra.captureFlipVertical = checked
}
diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cpp
index fe5599a6..8927a535 100644
--- a/src/source/CaptureCardSource.cpp
+++ b/src/source/CaptureCardSource.cpp
@@ -11,6 +11,7 @@
#include <avrt.h>
#include "veyra/source/CaptureBuffer.h"
#include "veyra/source/CaptureFormatRank.h"
+#include "veyra/source/CaptureFrameIntervals.h"
#include "veyra/source/CaptureCodec.h"
#include "veyra/source/CaptureCompressedDecoder.h"
#include "veyra/source/AverMediaAudioSwitch.h"
@@ -741,20 +742,33 @@ std::wstring CaptureCardSource::makeCapturePath(unsigned videoIndex,const Captur
if(video.path.empty()||(audioMode>=0&&(!audio||audio->path.empty())))return std::format(L"capture:{}:{}:{}:{}{}",videoIndex,format,audioMode,colorOverride,suffix);
return std::format(L"capture2:{}:{}:{}:{}:{}{}",encodePath(video.path),format,audioMode,audioMode>=0?encodePath(audio->path):L"",colorOverride,suffix);
}
-std::vector<CaptureFormat> enumerateFormats(IAMStreamConfig* config,bool preferDriverCurrent=false){
+std::vector<CaptureFormat> enumerateFormats(IAMStreamConfig* config,bool preferDriverCurrent=false,IBaseFilter* device=nullptr,IPin* capturePin=nullptr){
std::vector<CaptureFormat> out;if(!config)return out;int count=0,size=0;
+ ComPtr<IPin> pin=capturePin;if(!pin)config->QueryInterface(IID_PPV_ARGS(&pin));
+ ComPtr<IAMVideoControl> control;if(device)device->QueryInterface(IID_PPV_ARGS(&control));
+ if(!control&&pin)pin->QueryInterface(IID_PPV_ARGS(&control));
std::wstring currentKey;
if(preferDriverCurrent){AM_MEDIA_TYPE* current=nullptr;const HRESULT hr=config->GetFormat(&current);
if(SUCCEEDED(hr)&&current)currentKey=captureFormatIdentity(*current);
log::info("capture-default-format",std::format("GetFormat hr=0x{:08X} key={} configurationOnly=1 notSignalDetection=1",uint32_t(hr),narrowForLog(currentKey)));freeType(current);}
- if(FAILED(config->GetNumberOfCapabilities(&count,&size))||size<1||size>65536)return out;
+ const HRESULT capsHr=config->GetNumberOfCapabilities(&count,&size);
+ log::info("capture-formats",std::format("GetNumberOfCapabilities hr=0x{:08X} count={} bytes={} discreteRates={}",uint32_t(capsHr),count,size,bool(control&&pin)));
+ if(FAILED(capsHr)||count<0||size<1||size>65536)return out;
std::vector<BYTE> caps(size);
- for(int i=0;i<count;++i){AM_MEDIA_TYPE* type=nullptr;if(FAILED(config->GetStreamCaps(i,&type,caps.data())))continue;BITMAPINFOHEADER* bitmap=nullptr;REFERENCE_TIME duration=0;
+ for(int i=0;i<count;++i){AM_MEDIA_TYPE* type=nullptr;const HRESULT typeHr=config->GetStreamCaps(i,&type,caps.data());
+ if(FAILED(typeHr)){log::warn("capture-formats",std::format("GetStreamCaps index={} hr=0x{:08X}",i,uint32_t(typeHr)));freeType(type);continue;}BITMAPINFOHEADER* bitmap=nullptr;REFERENCE_TIME duration=0;
if(type&&type->pbFormat&&type->formattype==FORMAT_VideoInfo&&type->cbFormat>=sizeof(VIDEOINFOHEADER)){auto* info=reinterpret_cast<VIDEOINFOHEADER*>(type->pbFormat);bitmap=&info->bmiHeader;duration=info->AvgTimePerFrame;}
else if(type&&type->pbFormat&&type->formattype==FORMAT_VideoInfo2&&type->cbFormat>=sizeof(VIDEOINFOHEADER2)){auto* info=reinterpret_cast<VIDEOINFOHEADER2*>(type->pbFormat);bitmap=&info->bmiHeader;duration=info->AvgTimePerFrame;}
// Device capabilities, not a 1080p/2160p 30/60 preset list. Keep native
// indices so the selected row opens the exact driver media type.
- if(bitmap&&bitmap->biWidth>0&&bitmap->biWidth<=3840&&std::abs(int64_t(bitmap->biHeight))>0&&std::abs(int64_t(bitmap->biHeight))<=2160&&duration>0){unsigned width=bitmap->biWidth,height=unsigned(std::abs(int64_t(bitmap->biHeight)));double fps=1e7/duration;
+ if(bitmap&&bitmap->biWidth>0&&bitmap->biHeight!=0&&bitmap->biHeight!=LONG_MIN&&duration>=0){unsigned width=bitmap->biWidth,height=unsigned(std::abs(int64_t(bitmap->biHeight)));
+ HRESULT ratesHr=E_NOINTERFACE;
+ const auto intervals=captureFrameIntervals(control.Get(),pin.Get(),i,{LONG(width),LONG(height)},duration,&ratesHr);
+ if(control&&pin)log::info("capture-formats",std::format("GetFrameRateList index={} size={}x{} hr=0x{:08X} intervals={}",i,width,height,uint32_t(ratesHr),intervals.size()));
+ for(const auto interval:intervals){
+ if(type->formattype==FORMAT_VideoInfo)reinterpret_cast<VIDEOINFOHEADER*>(type->pbFormat)->AvgTimePerFrame=interval;
+ else reinterpret_cast<VIDEOINFOHEADER2*>(type->pbFormat)->AvgTimePerFrame=interval;
+ const double fps=interval>0?1e7/interval:0;
const auto pixel=capturePixelName(type->subtype);CaptureMediaLayout layout;const bool valid=captureMediaLayout(*type,layout);const bool knownRaw=capturePacking(type->subtype)!=CapturePacking::Unknown;
const wchar_t* support=valid?((layout.format==AV_PIX_FMT_P010||layout.format==AV_PIX_FMT_P016)?L"原生 · SDR":L"原生"):knownRaw?L"布局/颜色暂不支持":L"需系统解码/转换";
// N3: latency tier + recommended rank; compressed/unknown sorts last.
@@ -766,7 +780,10 @@ std::vector<CaptureFormat> enumerateFormats(IAMStreamConfig* config,bool preferD
interlaced=(flags&AMINTERLACE_IsInterlaced)!=0;
scan=interlaced?std::format(L"隔行({:.2f} 场/秒)",fps*((flags&AMINTERLACE_1FieldPerSample)?1:2)):L"逐行";}
const std::wstring scanMark=scan.empty()?std::wstring{}:L" · "+scan;
- out.push_back({i,width,height,fps,std::format(L"{} x {} @ {:.2f} fps{} · {} · {} · {}{} [format {}]",width,height,fps,scanMark,pixel,support,captureFormatTierLabel(tier),current?L" · 驱动默认":L"",i),key,rank,int(tier),current,pixel,scan,interlaced});
+ const bool supported=width<=3840&&height<=2160&&(!knownRaw||valid);
+ if(std::none_of(out.begin(),out.end(),[&](const CaptureFormat& f){return f.key==key;}))
+ out.push_back({i,width,height,fps,std::format(L"{} x {} @ {:.3f} fps{} · {} · {} · {}{}{} [format {}]",width,height,fps,scanMark,pixel,support,captureFormatTierLabel(tier),current?L" · 驱动默认":L"",supported?L"":L" · 当前播放器不支持",i),key,rank,int(tier),current,pixel,scan,interlaced,interval,supported});
+ }
}
freeType(type);
}
@@ -778,19 +795,21 @@ std::vector<CaptureFormat> CaptureCardSource::formats(unsigned device){
const auto details=deviceDetails();if(device<details.size()&&decklink::isPath(details[device].path))return formatsByPath(details[device].path);
ComPtr<IGraphBuilder> g;ComPtr<ICaptureGraphBuilder2>b;ComPtr<IBaseFilter>f;ComPtr<IAMStreamConfig>c;if(!configuration(device,g,b,f,c))return {};
const auto list=monikers(false);const auto name=device<list.size()?propertyString(list[device].Get(),L"FriendlyName"):L"";
- return enumerateFormats(c.Get(),isBlackmagicCaptureDevice(name));
+ ComPtr<IPin> pin;b->FindPin(f.Get(),PINDIR_OUTPUT,&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,FALSE,0,&pin);
+ return enumerateFormats(c.Get(),isBlackmagicCaptureDevice(name),f.Get(),pin.Get());
}
std::vector<CaptureFormat> CaptureCardSource::formatsByPath(std::wstring_view devicePath){
if(decklink::isPath(devicePath)){
std::vector<CaptureFormat> out;
for(const auto& device:decklink::devices())if(device.path==devicePath&&device.autoDetection)
- out.push_back({0,0,0,0,L"自动检测实际信号 · BMD 原生",decklink::modeKey(0),0,0,true});
+ out.push_back({0,0,0,0,L"自动检测实际信号 · BMD 原生",decklink::modeKey(0),0,0,true,L"自动选择像素格式",L"",false,0,true,true});
int index=1;for(const auto& mode:decklink::modes(devicePath))out.push_back({index++,mode.width,mode.height,double(mode.scale)/mode.duration,
- std::format(L"{} · {} x {} @ {:.3f} fps · {} · BMD 原生",mode.name,mode.width,mode.height,double(mode.scale)/mode.duration,mode.interlaced?L"隔行":L"逐行"),decklink::modeKey(mode.id),1,0,false});
+ std::format(L"{} · {} x {} @ {:.3f} fps · {} · BMD 原生",mode.name,mode.width,mode.height,double(mode.scale)/mode.duration,mode.interlaced?L"隔行":L"逐行"),decklink::modeKey(mode.id),1,0,false,L"自动选择像素格式",mode.interlaced?L"隔行":L"逐行",mode.interlaced,int64_t(1e7*mode.duration/mode.scale),mode.width<=3840&&mode.height<=2160});
return out;
}
ComPtr<IGraphBuilder> g;ComPtr<ICaptureGraphBuilder2>b;ComPtr<IBaseFilter>f;ComPtr<IAMStreamConfig>c;if(!configuration(devicePath,g,b,f,c))return {};
- return enumerateFormats(c.Get(),isBlackmagicCaptureDevice(captureDeviceName(devicePath),devicePath));
+ ComPtr<IPin> pin;b->FindPin(f.Get(),PINDIR_OUTPUT,&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,FALSE,0,&pin);
+ return enumerateFormats(c.Get(),isBlackmagicCaptureDevice(captureDeviceName(devicePath),devicePath),f.Get(),pin.Get());
}
bool CaptureCardSource::showDeviceProperties(std::wstring_view devicePath,uintptr_t owner,bool inputSelector,std::wstring& error,std::wstring* changedFormatKey){
error.clear();if(changedFormatKey)changedFormatKey->clear();
@@ -915,23 +934,25 @@ bool CaptureCardSource::configureDeckLink(const SourceOpenDesc& desc){
bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.clear();p_->lastAudioGain=-1;auto& p=*p_;CaptureSelection selection;if(!parseCapturePath(desc.path,selection))return false;const unsigned index=selection.videoIndex;int format=selection.format;const int audio=selection.audio;
if(selection.stable&&decklink::isPath(selection.videoPath))return configureDeckLink(desc);
if(selection.stable?!configuration(selection.videoPath,p.graph,p.builder,p.device,p.config):!configuration(index,p.graph,p.builder,p.device,p.config))return false;
- const auto available=enumerateFormats(p.config.Get());
+ ComPtr<IPin> formatPin;p.builder->FindPin(p.device.Get(),PINDIR_OUTPUT,&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,FALSE,0,&formatPin);
+ const auto available=enumerateFormats(p.config.Get(),false,p.device.Get(),formatPin.Get());
const auto* chosen=selectCaptureFormat(available,format,selection.formatKey);
if(!selection.formatKey.empty()&&!chosen){error_=L"保存的采集格式已不可用,请重新选择分辨率、帧率和像素格式。";return false;}
if(chosen)format=chosen->index;
+ if(chosen&&!chosen->supported){error_=L"设备提供此格式,但当前播放器不支持其尺寸或像素布局,请选择其他格式";return false;}
// Capture the advertised identity before SetFormat: some drivers mutate
// their capability list to reflect the last negotiated rate/orientation.
const std::wstring selectedKey=chosen?chosen->key:L"";
const double expectedFps=selection.requestedFps>0?selection.requestedFps:chosen?chosen->fps:0;
int count=0,size=0;if(FAILED(p.config->GetNumberOfCapabilities(&count,&size))||format<0||format>=count||size<=0||size>65536)return false;
std::vector<BYTE> caps(size);AM_MEDIA_TYPE* native=nullptr;if(FAILED(p.config->GetStreamCaps(format,&native,caps.data())))return false;
- if(selection.requestedFps>0){
+ if(selection.requestedFps>0||(chosen&&chosen->interval100ns>0)){
REFERENCE_TIME* interval=nullptr;
if(native->formattype==FORMAT_VideoInfo&&native->cbFormat>=sizeof(VIDEOINFOHEADER))interval=&reinterpret_cast<VIDEOINFOHEADER*>(native->pbFormat)->AvgTimePerFrame;
else if(native->formattype==FORMAT_VideoInfo2&&native->cbFormat>=sizeof(VIDEOINFOHEADER2))interval=&reinterpret_cast<VIDEOINFOHEADER2*>(native->pbFormat)->AvgTimePerFrame;
if(!interval){error_=L"该采集格式不支持设备帧率协商,请将采集帧率设为 0。";freeType(native);return false;}
- *interval=captureFrameInterval(selection.requestedFps);
- log::info("capture-rate",std::format("requestFps={:.6f} interval100ns={} deviceNegotiation=1 softwareLimiter=0",selection.requestedFps,*interval));
+ *interval=selection.requestedFps>0?captureFrameInterval(selection.requestedFps):chosen->interval100ns;
+ log::info("capture-rate",std::format("requestFps={:.6f} interval100ns={} deviceNegotiation=1 softwareLimiter=0",expectedFps,*interval));
}
std::wstring devicePath=selection.videoPath;
if(devicePath.empty()){const auto devices=monikers(false);if(index<devices.size())devicePath=monikerPath(devices[index].Get());}
diff --git a/src/source/DeckLinkCapture.cpp b/src/source/DeckLinkCapture.cpp
index 8015426d..ae84c773 100644
--- a/src/source/DeckLinkCapture.cpp
+++ b/src/source/DeckLinkCapture.cpp
@@ -92,8 +92,9 @@ bool Capture::configure(std::wstring_view path,std::wstring_view key,bool audio,
const bool automatic=key==L"decklink:auto"||key.empty();
{std::lock_guard lock(p.mutex);p.automatic=automatic;}
if(automatic&&!p.driver->autoDetection())return failed(L"这张 BMD 卡不支持自动检测,请选择与信号一致的手动制式");
- const auto chosen=std::find_if(available.begin(),available.end(),[&](const Mode& m){return automatic||modeKey(m.id)==key;});
+ const auto chosen=std::find_if(available.begin(),available.end(),[&](const Mode& m){return automatic?(m.width<=3840&&m.height<=2160):modeKey(m.id)==key;});
if(chosen==available.end())return failed(L"保存的 BMD 制式不可用,请重新选择");
+ if(chosen->width>3840||chosen->height>2160)return failed(L"设备提供此制式,但当前播放器的 BMD 采集最高支持 3840×2160");
auto enable=[&](const Mode& mode,Pixel pixel){
{std::lock_guard lock(p.mutex);p.mode=mode;p.pixel=pixel;p.valid=false;}
const bool ok=p.driver->enable(mode,pixel,automatic,audio,why);if(ok)why.clear();return ok;
diff --git a/src/source/DeckLinkDriver.cpp b/src/source/DeckLinkDriver.cpp
index 6d4c1986..80a1d5b9 100644
--- a/src/source/DeckLinkDriver.cpp
+++ b/src/source/DeckLinkDriver.cpp
@@ -80,7 +80,7 @@ std::vector<Mode> readModes(IDeckLinkInput* input){
if(!checked(input->GetDisplayModeIterator(&iterator),"GetDisplayModeIterator"))return out;
ComPtr<IDeckLinkDisplayMode> mode;
while(iterator->Next(&mode)==S_OK){auto m=describe(mode.Get());
- if(m.width>=2&&m.width<=3840&&m.height&&m.height<=2160&&m.duration>0&&m.scale>0)out.push_back(std::move(m));mode.Reset();}
+ if(m.width>=2&&m.height&&m.duration>0&&m.scale>0)out.push_back(std::move(m));mode.Reset();}
// A conservative seed only. The format-change callback, not this order,
// selects the real automatic mode before any frame can be published.
std::stable_sort(out.begin(),out.end(),[](const Mode& a,const Mode& b){const auto seed=[](const Mode& m){return m.width==1920&&m.height==1080&&!m.interlaced&&m.scale==m.duration*60;};return seed(a)&&!seed(b);});
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index 4b88c64c..913e644f 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -32,6 +32,7 @@
#include <QJsonArray>
#include <QHash>
#include <QFile>
+#include <QSaveFile>
#include <QTimer>
#include <QBuffer>
#include <QImage>
@@ -336,6 +337,7 @@ struct QmlPlayerBridge::Impl {
// --- capture connection (P4-e) ---
struct CaptureQuery { int kind = 0; std::wstring device; std::vector<source::CaptureDevice> video, audio; std::vector<source::CaptureFormat> formats; };
std::future<CaptureQuery> captureQuery;
+ std::optional<std::pair<int,std::wstring>> captureNextQuery;
bool captureBusy = false, captureListed = false, captureResumePending = false;
bool captureDriverSettingsOpen = false;
std::wstring captureDriverFormatKey;
@@ -344,6 +346,7 @@ struct QmlPlayerBridge::Impl {
std::vector<source::CaptureFormat> captureFormatList;
std::wstring captureFormatKey;
int captureAudioChoice = source::kCaptureAudioDisabled;
+ bool captureAudioMissing = false;
unsigned captureColor = 0;
double captureFps = 0;
QString captureStatus;
@@ -476,17 +479,47 @@ struct QmlPlayerBridge::Impl {
// on a new profile used to fail and was silently kept only in memory.
std::error_code ec;
std::filesystem::create_directories(prefsFile().parent_path(), ec);
- QFile file(path + QStringLiteral(".tmp"));
- if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) return false;
+ if(ec)return false;
+ QSaveFile file(path);
+ if (!file.open(QIODevice::WriteOnly)) return false;
const auto bytes = QJsonDocument(QJsonObject::fromVariantMap(prefs)).toJson(QJsonDocument::Indented);
- if (file.write(bytes) != bytes.size()) { file.close(); file.remove(); return false; }
- file.close();
- QFile::remove(path);
- return QFile::rename(path + QStringLiteral(".tmp"), path);
+ if (file.write(bytes) != bytes.size()) return false;
+ return file.commit();
}
int prefInt(const char* key, int fallback) const { return prefs.contains(key) ? prefs.value(key).toInt() : fallback; }
bool prefBool(const char* key, bool fallback) const { return prefs.contains(key) ? prefs.value(key).toBool() : fallback; }
QString prefString(const char* key) const { return prefs.value(key).toString(); }
+ void restoreCaptureForm() {
+ captureFps=capturePrefs.requestedFps;
+ captureColor=capturePrefs.colorForDevice(captureDevice);
+ captureAudioChoice=source::kCaptureAudioDisabled;
+ captureAudioMissing=false;
+ if(capturePrefs.audioMode==source::kCaptureAudioFromVideoDevice)captureAudioChoice=source::kCaptureAudioFromVideoDevice;
+ else if(!capturePrefs.audioPath.empty()){
+ captureAudioMissing=true;
+ for(size_t k=0;k<captureAudio.size();++k)
+ if(captureAudio[k].path==capturePrefs.audioPath&&captureAudio[k].wasapi==(capturePrefs.audioMode==source::kCaptureAudioWasapi)){
+ captureAudioChoice=int(k);captureAudioMissing=false;break;
+ }
+ }
+ }
+ bool persistCaptureSelection() {
+ if(captureDevice.empty())return true; // Disconnecting a card must retain it.
+ const bool sameDevice=capturePrefs.videoPath==captureDevice;
+ capturePrefs.videoPath=captureDevice;
+ // An unavailable saved type has no active selection. Editing another
+ // control must retain its key until the user explicitly picks a new type.
+ if(!captureFormatKey.empty()||!sameDevice)capturePrefs.formatKey=captureFormatKey;
+ capturePrefs.colorOverride=captureColor;capturePrefs.requestedFps=captureFps;
+ if(capturePrefs.deviceColors.size()<128||capturePrefs.deviceColors.contains(captureDevice))capturePrefs.deviceColors[captureDevice]=captureColor;
+ if(!captureAudioMissing){
+ const auto* audio=captureAudioChoice>=0&&size_t(captureAudioChoice)<captureAudio.size()?&captureAudio[size_t(captureAudioChoice)]:nullptr;
+ capturePrefs.audioPath=audio?audio->path:std::wstring{};
+ capturePrefs.audioMode=audio?(audio->wasapi?source::kCaptureAudioWasapi:0):captureAudioChoice;
+ }
+ if(ui::CapturePreferenceStore(dataDir).save(capturePrefs))return true;
+ veyra::log::error("capture-ui","capture settings could not be saved");return false;
+ }
Impl(engine::EngineController& e, std::filesystem::path dataDirectory)
: engine(e), facade(e, dataDirectory),
dataDir(dataDirectory.empty() ? runtime::localDataDirectory() : dataDirectory) {
@@ -1186,6 +1219,10 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
};
restoreHold("nrHoldStrength", s.nrHoldStrength);
restoreHold("nrHoldTolerance", s.nrHoldTolerance);
+ for(const auto& pair : {std::pair{"captureFlipVertical",&s.captureFlipVertical},std::pair{"captureForceSdr",&s.forceSdrPreview}})
+ if(p.contains(QLatin1String(pair.first))){const bool value=p.value(QLatin1String(pair.first)).toBool();changed|=*pair.second!=value;*pair.second=value;}
+ if(p.contains("captureAudioIngress")){const int value=p.value("captureAudioIngress").toInt();if(value>=0&&value<=2){changed|=int(s.captureAudio)!=value;s.captureAudio=static_cast<engine::CaptureAudioIngress>(value);}}
+ if(p.contains("captureBufferMode")){const int value=p.value("captureBufferMode").toInt();if(value>=0&&value<=2){changed|=int(s.captureBuffer)!=value;s.captureBuffer=static_cast<source::CaptureBufferMode>(value);}}
if (changed && !impl_->commit(std::move(s))) veyra::log::warn("ui-prefs", "saved global controls not accepted");
}
// Presentation (低延迟队列 / 显示同步 / 输出上限) and the picture aspect.
@@ -2026,12 +2063,15 @@ void QmlPlayerBridge::setCaptureDeviceId(const QString& value) {
if (impl_->captureDriverSettingsOpen) return;
if (impl_->captureDevice == wideOf(value)) return;
impl_->captureDevice = wideOf(value);
- impl_->captureFormatList.clear(); impl_->captureFormatKey.clear();
+ impl_->captureFormatList.clear();
+ impl_->captureFormatKey=impl_->captureDevice==impl_->capturePrefs.videoPath?impl_->capturePrefs.formatKey:std::wstring{};
impl_->captureDriverFormatKey.clear();
// Colour follows the device, as in 1.4.4; audio returns to "none" unless it
// is the remembered device.
impl_->captureColor = impl_->capturePrefs.colorForDevice(impl_->captureDevice);
- if (impl_->captureDevice != impl_->capturePrefs.videoPath) impl_->captureAudioChoice = source::kCaptureAudioDisabled;
+ if(impl_->captureDevice==impl_->capturePrefs.videoPath)impl_->restoreCaptureForm();
+ else {impl_->captureAudioChoice=source::kCaptureAudioDisabled;impl_->captureAudioMissing=false;}
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
if (!impl_->captureDevice.empty()) queryCapture(1, impl_->captureDevice);
emit captureChanged();
}
@@ -2054,14 +2094,16 @@ QVariantList QmlPlayerBridge::captureFormats() const {
QString QmlPlayerBridge::captureFormatKey() const { return utf8Of(impl_->captureFormatKey); }
void QmlPlayerBridge::setCaptureFormatKey(const QString& key) {
if (impl_->captureFormatKey == wideOf(key)) return;
+ if(!source::selectCaptureFormat(impl_->captureFormatList,-1,wideOf(key)))return;
impl_->captureFormatKey = wideOf(key);
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
emit captureChanged();
}
namespace {
QVariantList captureChoiceList(const std::vector<source::CaptureFormatOption>& options) {
QVariantList out;
for (const auto& option : options)
- out << QVariantMap{{"id", utf8Of(option.id)}, {"label", uiText(option.label)}};
+ out << QVariantMap{{"id", utf8Of(option.id)}, {"label", uiText(option.label)}, {"disabled",option.disabled}};
return out;
}
const source::CaptureFormat* selectedCaptureFormat(const std::vector<source::CaptureFormat>& formats, const std::wstring& key) {
@@ -2081,8 +2123,7 @@ void QmlPlayerBridge::setCaptureResolutionId(const QString& id) {
if (current && source::captureResolutionId(*current) == wide) return;
const auto* next = source::retargetCaptureFormat(impl_->captureFormatList, current, source::CaptureFormatAxis::Resolution, wide);
if (!next || next->key == impl_->captureFormatKey) return;
- impl_->captureFormatKey = next->key;
- emit captureChanged();
+ setCaptureFormatKey(utf8Of(next->key));
}
QVariantList QmlPlayerBridge::captureFrameRateOptions() const {
return captureChoiceList(source::captureFrameRateOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));
@@ -2097,8 +2138,7 @@ void QmlPlayerBridge::setCaptureFrameRateId(const QString& id) {
if (!current || source::captureFrameRateId(*current) == wide) return;
const auto* next = source::retargetCaptureFormat(impl_->captureFormatList, current, source::CaptureFormatAxis::FrameRate, wide);
if (!next || next->key == impl_->captureFormatKey) return;
- impl_->captureFormatKey = next->key;
- emit captureChanged();
+ setCaptureFormatKey(utf8Of(next->key));
}
QVariantList QmlPlayerBridge::capturePixelOptions() const {
return captureChoiceList(source::capturePixelOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey)));
@@ -2113,14 +2153,14 @@ void QmlPlayerBridge::setCapturePixelId(const QString& id) {
const auto options = source::capturePixelOptions(impl_->captureFormatList, selectedCaptureFormat(impl_->captureFormatList, impl_->captureFormatKey));
for (const auto& option : options) {
if (option.id != key) continue;
- impl_->captureFormatKey = key;
- emit captureChanged();
+ setCaptureFormatKey(id);
return;
}
}
QVariantList QmlPlayerBridge::captureAudioInputs() const {
// Only what the user picks explicitly is ever opened (1.4.4 rule).
QVariantList out{QVariantMap{{"id", source::kCaptureAudioDisabled}, {"label", tr("不监听音频")}}};
+ if(impl_->captureAudioMissing)out<<QVariantMap{{"id",-4},{"label",tr("上次的音频输入未连接")},{"disabled",true}};
for (const auto& d : impl_->captureVideo)
if (d.path == impl_->captureDevice)
out << QVariantMap{{"id", source::kCaptureAudioFromVideoDevice},
@@ -2129,30 +2169,29 @@ QVariantList QmlPlayerBridge::captureAudioInputs() const {
out << QVariantMap{{"id", int(i)}, {"label", QStringLiteral("[%1] %2").arg(impl_->captureAudio[i].wasapi ? QStringLiteral("WASAPI") : QStringLiteral("DirectShow"), utf8Of(impl_->captureAudio[i].name))}};
return out;
}
-int QmlPlayerBridge::captureAudioChoice() const { return impl_->captureAudioChoice; }
+int QmlPlayerBridge::captureAudioChoice() const { return impl_->captureAudioMissing?-4:impl_->captureAudioChoice; }
void QmlPlayerBridge::setCaptureAudioChoice(int choice) {
if (choice < source::kCaptureAudioFromVideoDevice || choice >= int(impl_->captureAudio.size())) return;
impl_->captureAudioChoice = choice;
+ impl_->captureAudioMissing=false;
// Remember the audio choice for this device as soon as it is picked, not only on
// 连接并开始 (field report 2026-10-01: picked, closed, and it was gone next time).
- auto& i = *impl_;
- if (!i.captureDevice.empty() && i.captureDevice == i.capturePrefs.videoPath) {
- const source::CaptureDevice* audio = choice >= 0 && size_t(choice) < i.captureAudio.size() ? &i.captureAudio[size_t(choice)] : nullptr;
- i.capturePrefs.audioPath = audio ? audio->path : std::wstring{};
- i.capturePrefs.audioMode = audio ? (audio->wasapi ? source::kCaptureAudioWasapi : 0) : choice;
- if (!ui::CapturePreferenceStore(i.dataDir).save(i.capturePrefs)) veyra::log::warn("capture-ui", "capture audio choice not saved");
- }
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
emit captureChanged();
}
int QmlPlayerBridge::captureColorSpace() const { return int(source::captureColorSpace(impl_->captureColor)); }
void QmlPlayerBridge::setCaptureColorSpace(int value) {
if (value < 0 || value > 3) return;
- impl_->captureColor = source::captureColorOverride(unsigned(value), source::captureColorRange(impl_->captureColor)); emit captureChanged();
+ impl_->captureColor = source::captureColorOverride(unsigned(value), source::captureColorRange(impl_->captureColor));
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
+ emit captureChanged();
}
int QmlPlayerBridge::captureColorRange() const { return int(source::captureColorRange(impl_->captureColor)); }
void QmlPlayerBridge::setCaptureColorRange(int value) {
if (value < 0 || value > 2) return;
- impl_->captureColor = source::captureColorOverride(source::captureColorSpace(impl_->captureColor), unsigned(value)); emit captureChanged();
+ impl_->captureColor = source::captureColorOverride(source::captureColorSpace(impl_->captureColor), unsigned(value));
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
+ emit captureChanged();
}
double QmlPlayerBridge::captureRequestedFps() const { return impl_->captureFps; }
void QmlPlayerBridge::setCaptureRequestedFps(double value) {
@@ -2161,11 +2200,7 @@ void QmlPlayerBridge::setCaptureRequestedFps(double value) {
impl_->captureFps = value;
// Saved as soon as it is typed, as the audio choice is (field report 2026-10-01: the
// new rate was lost unless another option was changed before closing).
- auto& i = *impl_;
- if (!i.captureDevice.empty() && i.captureDevice == i.capturePrefs.videoPath) {
- i.capturePrefs.requestedFps = value;
- if (!ui::CapturePreferenceStore(i.dataDir).save(i.capturePrefs)) veyra::log::warn("capture-ui", "capture frame rate not saved");
- }
+ if(!impl_->persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
veyra::log::info("capture-ui", std::format("requested fps={}", value));
emit captureChanged();
}
@@ -2173,13 +2208,15 @@ int QmlPlayerBridge::captureAudioIngress() const { return int(settings().capture
void QmlPlayerBridge::setCaptureAudioIngress(int value) {
if (value < 0 || value > 2) return;
auto s = settings(); s.captureAudio = static_cast<engine::CaptureAudioIngress>(value);
- impl_->commit(std::move(s)); emit settingsChanged();
+ if(impl_->commit(std::move(s))){impl_->prefs["captureAudioIngress"]=value;if(!impl_->savePrefs())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);}
+ emit settingsChanged();
}
int QmlPlayerBridge::captureBufferMode() const { return int(settings().captureBuffer); }
void QmlPlayerBridge::setCaptureBufferMode(int value) {
if (value < 0 || value > 2) return;
auto s = settings(); s.captureBuffer = static_cast<source::CaptureBufferMode>(value);
- impl_->commit(std::move(s)); emit settingsChanged();
+ if(impl_->commit(std::move(s))){impl_->prefs["captureBufferMode"]=value;if(!impl_->savePrefs())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);}
+ emit settingsChanged();
}
bool QmlPlayerBridge::captureQueryBusy() const { return impl_->captureBusy || impl_->captureDriverSettingsOpen; }
QString QmlPlayerBridge::captureStatus() const { return impl_->captureStatus; }
@@ -2217,7 +2254,7 @@ void QmlPlayerBridge::refreshCaptureDevices() {
}
void QmlPlayerBridge::queryCapture(int kind, std::wstring device) {
auto& i = *impl_;
- if (captureQueryBusy()) { if (kind == 0) i.captureStatus = tr("正在查询设备…"); return; }
+ if (captureQueryBusy()) { i.captureNextQuery=std::pair{kind,std::move(device)};return; }
i.captureBusy = true; i.captureQueryKind = kind;
i.captureStatus = kind == 0 ? tr("正在查询采集设备…当前播放继续") : tr("正在读取设备支持的格式…");
i.captureQuery = std::async(std::launch::async, [kind, device] {
@@ -2240,20 +2277,13 @@ void QmlPlayerBridge::tickCapture() {
if (!i.captureBusy || i.captureQuery.wait_for(std::chrono::seconds(0)) != std::future_status::ready) return;
auto q = i.captureQuery.get();
i.captureBusy = false;
+ if(i.captureNextQuery){auto next=std::move(*i.captureNextQuery);i.captureNextQuery.reset();queryCapture(next.first,std::move(next.second));return;}
if (q.kind == 0 || q.kind == 2) { i.captureVideo = std::move(q.video); i.captureAudio = std::move(q.audio); i.captureListed = true; }
// The remembered rate and audio input, matched against the inputs listed now. Both the
// panel (kind 0) and 继续上次 (kind 2) need it: the resume path skipped it and connected
// without sound until the panel was opened once (field report 2026-10-02).
const auto restoreRememberedAudio = [&i] {
- i.captureFps = i.capturePrefs.requestedFps;
- const int mode = i.capturePrefs.audioMode;
- if (mode == source::kCaptureAudioFromVideoDevice) i.captureAudioChoice = mode;
- else if (!i.capturePrefs.audioPath.empty()) {
- i.captureAudioChoice = source::kCaptureAudioDisabled;
- for (size_t k = 0; k < i.captureAudio.size(); ++k)
- if (i.captureAudio[k].path == i.capturePrefs.audioPath &&
- i.captureAudio[k].wasapi == (mode == source::kCaptureAudioWasapi)) i.captureAudioChoice = int(k);
- } else i.captureAudioChoice = source::kCaptureAudioDisabled;
+ i.restoreCaptureForm();
};
if (q.kind == 2 && q.device == i.capturePrefs.videoPath) restoreRememberedAudio();
if (q.kind == 0) {
@@ -2291,7 +2321,8 @@ void QmlPlayerBridge::tickCapture() {
} else if (remembered && !i.capturePrefs.formatKey.empty()) {
if (const auto* f = source::selectCaptureFormat(i.captureFormatList, -1, i.capturePrefs.formatKey)) i.captureFormatKey = f->key;
} else if (!i.captureFormatList.empty()) i.captureFormatKey = i.captureFormatList.front().key;
- i.captureStatus = i.captureFormatList.empty() ? tr("未读到有效的 4K 以内采集格式,或设备正被其他应用占用。")
+ if(!i.captureFormatKey.empty()&&!i.persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
+ i.captureStatus = i.captureFormatList.empty() ? tr("未读到设备上报的采集格式,或设备正被其他应用占用。")
: i.captureFormatKey.empty() ? tr("上次格式已不可用,请重新选择格式。")
: q.kind == 3 ? tr("驱动设置已关闭。请核对所选格式与设备帧率,再连接。")
: source::decklink::isPath(i.captureDevice) ? tr("原生采集先确认有效信号;支持自动检测的卡建议选择自动。HDMI/SDI 跟随 Desktop Video Setup。")
@@ -2314,16 +2345,14 @@ bool QmlPlayerBridge::startCaptureSession() {
emit notice(tr("采集接口已切换,请刷新并重新选择设备和格式"),true);return false;
}
if (device < 0 || !format) { emit notice(tr("请先选择采集设备和格式"), true); return false; }
+ if(!format->supported){emit notice(tr("设备提供此格式,但当前播放器不支持其尺寸或像素布局,请选择其他格式"),true);return false;}
+ if(i.captureAudioMissing){emit notice(tr("上次的音频输入未连接,请插回设备或重新选择音频监听"),true);return false;}
const int audio = i.captureAudioChoice;
const source::CaptureDevice* audioDevice = audio >= 0 && size_t(audio) < i.captureAudio.size() ? &i.captureAudio[size_t(audio)] : nullptr;
const auto path = source::CaptureCardSource::makeCapturePath(unsigned(device), i.captureVideo[size_t(device)], format->index, audio,
audioDevice, i.captureColor, i.captureFps, format->key);
if (path.empty()) { emit notice(tr("无法生成采集连接参数"), true); return false; }
- auto colors = i.capturePrefs.deviceColors; colors[i.captureDevice] = i.captureColor;
- i.capturePrefs = {i.captureDevice, format->key, audioDevice ? audioDevice->path : std::wstring{},
- audioDevice ? (audioDevice->wasapi ? source::kCaptureAudioWasapi : 0) : audio, i.captureColor,
- i.capturePrefs.formatHintDismissed, i.captureFps, std::move(colors)};
- if (!ui::CapturePreferenceStore(i.dataDir).save(i.capturePrefs)) veyra::log::warn("capture-ui", "capture selection not saved");
+ if(!i.persistCaptureSelection())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);
i.facade.noteCaptureSession({i.captureDevice, format->key, i.facade.presets().entries().empty() ? std::wstring{} : wideOf(currentPresetName()),
i.captureFps > 0 ? i.captureFps : format->fps, true});
veyra::log::info("capture-ui", std::format("connect format={} audio={} color={} fps={}", QString::fromStdWString(format->label).toStdString(), audio, i.captureColor, i.captureFps));
@@ -2383,7 +2412,7 @@ void QmlPlayerBridge::setCaptureForceSdr(bool value) {
auto s = settings();
if (s.forceSdrPreview == value) return;
s.forceSdrPreview = value;
- impl_->commit(std::move(s));
+ if(impl_->commit(std::move(s))){impl_->prefs["captureForceSdr"]=value;if(!impl_->savePrefs())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);}
emit settingsChanged();
}
bool QmlPlayerBridge::captureFlipVertical() const { return settings().captureFlipVertical; }
@@ -2391,7 +2420,7 @@ void QmlPlayerBridge::setCaptureFlipVertical(bool value) {
auto s = settings();
if (s.captureFlipVertical == value) return;
s.captureFlipVertical = value;
- impl_->commit(std::move(s));
+ if(impl_->commit(std::move(s))){impl_->prefs["captureFlipVertical"]=value;if(!impl_->savePrefs())emit notice(tr("采集设置保存失败,请检查配置目录是否可写"),true);}
emit settingsChanged();
}
diff --git a/tests/unit/CaptureFormatSelectionTests.cpp b/tests/unit/CaptureFormatSelectionTests.cpp
index 5b37fd82..eea92f9a 100644
--- a/tests/unit/CaptureFormatSelectionTests.cpp
+++ b/tests/unit/CaptureFormatSelectionTests.cpp
@@ -1,7 +1,26 @@
#include "veyra/source/CaptureFormatSelection.h"
+#include "veyra/source/CaptureFrameIntervals.h"
#include <array>
#include <iostream>
#include <vector>
+#include <cstring>
+
+struct RateDriver final : IAMVideoControl {
+ std::vector<LONGLONG> intervals;HRESULT result=S_OK;long seenIndex=-1;SIZE seenSize{};
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID,void**) override{return E_NOINTERFACE;}
+ ULONG STDMETHODCALLTYPE AddRef() override{return 1;}
+ ULONG STDMETHODCALLTYPE Release() override{return 1;}
+ HRESULT STDMETHODCALLTYPE GetCaps(IPin*,long*) override{return E_NOTIMPL;}
+ HRESULT STDMETHODCALLTYPE SetMode(IPin*,long) override{return E_NOTIMPL;}
+ HRESULT STDMETHODCALLTYPE GetMode(IPin*,long*) override{return E_NOTIMPL;}
+ HRESULT STDMETHODCALLTYPE GetCurrentActualFrameRate(IPin*,LONGLONG*) override{return E_NOTIMPL;}
+ HRESULT STDMETHODCALLTYPE GetMaxAvailableFrameRate(IPin*,long,SIZE,LONGLONG*) override{return E_NOTIMPL;}
+ HRESULT STDMETHODCALLTYPE GetFrameRateList(IPin*,long index,SIZE dimensions,long* count,LONGLONG** data) override{
+ seenIndex=index;seenSize=dimensions;*count=long(intervals.size());
+ *data=static_cast<LONGLONG*>(CoTaskMemAlloc(intervals.size()*sizeof(LONGLONG)));
+ if(*data)std::memcpy(*data,intervals.data(),intervals.size()*sizeof(LONGLONG));return result;
+ }
+};
int main(){
using namespace veyra::source;
@@ -69,5 +88,35 @@ int main(){
check(keptPixel==&listed[4],"resolution change keeps YUY2 when that pixel exists at the new size");
const auto interlacedPixels=capturePixelOptions(listed,&listed[3]);
check(interlacedPixels.size()==1&&interlacedPixels[0].id==L"1080i60-nv12","interlaced rate does not offer the progressive NV12 row");
+ {
+ RateDriver driver;driver.intervals={166667,333667,417083,100000,0,-1,333667};
+ HRESULT hr=E_FAIL;auto* pin=reinterpret_cast<IPin*>(uintptr_t(1));
+ const auto rates=captureFrameIntervals(&driver,pin,19,{1448,1086},166667,&hr);
+ check(hr==S_OK&&driver.seenIndex==19&&driver.seenSize.cx==1448&&driver.seenSize.cy==1086,"queries current capability index and exact device dimensions");
+ check(rates==std::vector<REFERENCE_TIME>{166667,333667,417083,100000},"all discrete driver rates kept, invalid and duplicates removed without preset rates");
+ driver.result=E_NOTIMPL;
+ check(captureFrameIntervals(&driver,pin,2,{640,480},200000,&hr)==std::vector<REFERENCE_TIME>{200000}&&hr==E_NOTIMPL,"unavailable rate API retains exact advertised type");
+ check(captureFrameIntervals(nullptr,nullptr,0,{640,480},0)==std::vector<REFERENCE_TIME>{0},"unknown default interval stays visible");
+ }
+ {
+ auto unusual=media(25,1448,1086,47.952,L"unusual",L"CUSTOM",false,L"逐行");
+ auto huge=media(30,7680,4320,120,L"8k",L"P010",false,L"逐行");huge.supported=false;
+ CaptureFormat automatic;automatic.key=L"decklink:auto";automatic.automatic=true;automatic.pixel=L"自动选择像素格式";
+ std::vector<CaptureFormat> all{automatic,unusual,huge,unusual};
+ const auto sizes=captureResolutionOptions(all);
+ check(sizes.size()==3&&sizes[0].id==L"auto"&&sizes[0].label.find(L"0")==std::wstring::npos&&sizes[1].id==L"1448x1086"&&sizes[2].id==L"7680x4320","automatic, nonstandard and oversized device modes all visible");
+ check(captureFrameRateOptions(all,&all[0])[0].label==L"跟随实际信号","DeckLink automatic rate never displayed as zero fps");
+ check(capturePixelOptions(all,&all[1]).size()==1,"identical media keys are not duplicated");
+ const auto unsupported=capturePixelOptions(all,&all[2]);
+ check(unsupported.size()==1&&unsupported[0].disabled&&unsupported[0].label.find(L"不支持")!=std::wstring::npos,"unsupported driver format remains visible with explicit limit");
+ unusual.fps=1;unusual.interval100ns=10000000;huge.fps=1.0000001;huge.interval100ns=9999999;
+ check(captureFrameRateId(unusual)!=captureFrameRateId(huge),"exact driver intervals never collapse from decimal rounding");
+ for(const auto& format:all){
+ const auto* chosen=retargetCaptureFormat(all,nullptr,CaptureFormatAxis::Resolution,captureResolutionId(format));
+ check(chosen!=nullptr,"every reported resolution is reachable");
+ const auto options=capturePixelOptions(all,&format);
+ check(std::any_of(options.begin(),options.end(),[&](const CaptureFormatOption& option){return option.id==format.key;}),"every reported media identity is reachable through linked selectors");
+ }
+ }
std::cout<<"capture format selection failures="<<failures<<'\n';return failures?1:0;
}
diff --git a/tests/unit/DeckLinkCaptureTests.cpp b/tests/unit/DeckLinkCaptureTests.cpp
index 8f85cce5..640faa67 100644
--- a/tests/unit/DeckLinkCaptureTests.cpp
+++ b/tests/unit/DeckLinkCaptureTests.cpp
@@ -15,12 +15,13 @@ Mode makeMode(uint32_t id=1,unsigned width=1920){
struct FakeDriver:Driver {
DriverSink* sink=nullptr;Mode mode=makeMode();Pixel pixel=Pixel::V210;
bool automatic=true,noSignal=false,occupied=false,rejectTen=false,failFlush=false,failStart=false,sendRgbChange=false,detectDuringEnable=false;
+ bool oversizedFirst=false;
unsigned enabled=0,started=0,paused=0,flushed=0,stopped=0;
std::vector<uint8_t> pixels;
std::thread::id owner=std::this_thread::get_id();bool allControlsOnOwner=true;
void control(){allControlsOnOwner&=std::this_thread::get_id()==owner;}
bool open(std::wstring_view,DriverSink& target,std::wstring& error)override{control();sink=&target;if(occupied){error=L"busy";return false;}return true;}
- std::vector<Mode> modes()override{return {makeMode(),makeMode(2,1280)};}
+ std::vector<Mode> modes()override{auto out=std::vector<Mode>{makeMode(),makeMode(2,1280)};if(oversizedFirst){auto huge=makeMode(3,7680);huge.height=4320;out.insert(out.begin(),huge);}return out;}
bool autoDetection()const override{return automatic;}
bool enable(const Mode& m,Pixel p,bool,bool,std::wstring& error)override{control();++enabled;if(rejectTen&&(p==Pixel::V210||p==Pixel::Rgb10xLE)){error=L"unsupported";return false;}mode=m;pixel=p;
if(detectDuringEnable&&enabled==1){std::thread callback([&]{sink->formatChanged({makeMode(2,1280),true,10});});callback.join();}
@@ -45,6 +46,11 @@ int main(){
int failures=0;auto check=[&](bool value,const char* name){printf("%s %s\n",value?"PASS":"FAIL",name);if(!value)++failures;};
auto fixture=[](){auto driver=std::make_unique<FakeDriver>();auto* raw=driver.get();return std::pair{std::move(driver),raw};};
constexpr auto path=L"decklink-native:p:0000000000000123:0";
+ {
+ auto [driver,fake]=fixture();fake->oversizedFirst=true;Capture capture(std::move(driver));
+ check(capture.configure(path,L"decklink:auto",false,50)&&capture.mode().id==1,"all driver modes retained without choosing an unsupported automatic seed");
+ check(!capture.configure(path,modeKey(3),false,50)&&!capture.error().empty(),"oversized manual driver mode fails explicitly before enabling");
+ }
{
auto [driver,fake]=fixture();Capture capture(std::move(driver));unsigned video=0,audio=0;
check(capture.configure(path,L"decklink:auto",true,50),"valid signal probes without retaining a frame");