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(recording): correct the build errors found by the first compile

Veyra Goal Agent99bfc4396e85
diff --git a/docs/SCREEN_RECORDING_PLAN_2026-10-20.md b/docs/SCREEN_RECORDING_PLAN_2026-10-20.md
new file mode 100644
index 00000000..4ba684c0
--- /dev/null
+++ b/docs/SCREEN_RECORDING_PLAN_2026-10-20.md
@@ -0,0 +1,93 @@
+# 实时录制(处理后画面)施工方案 — 2026-10-20
+
+## 一、需求
+
+用户要求给软件增加录制功能:
+
+1. 录到**处理后的画面**(即 NR / 超分 / 补帧之后的画面,不是源画面);
+2. 设置页可设置**录制位置、码率**等;
+3. 专业模式在**截图按钮旁边**增加录制按钮,带**合适动画**与**3 秒倒计时**;
+4. 完成后构建新的**测试版本**交付用户实测。
+
+## 二、设计取舍
+
+### 2.1 录什么:呈现的那一帧
+
+录制挂在实时呈现点上:每次 `presenter.present()` 真正提交了画面,就把同一帧交给编码器。
+因此录到的是用户当时看到的那一帧,包含 NR、超分与补帧的结果。
+
+- 真实帧来自增强图的输出纹理(`graph->videoFrameResource(slot)`);
+- 补帧生成的帧来自生成池(`graph->generatedFrameResource(slot)`);
+- **XeSS 自行持有交换链**时,生成帧不在增强图里,录制只取真实帧。这与导出路径的限制一致
+ (导出侧同样拒绝 XeSS 补帧纹理),不假装能录到没有的像素。
+
+### 2.2 用哪个编码器:复用产品导出编码器
+
+`LiveRecorder` 直接使用 `sink::openVideoEncoder()`,即 N 卡的 NVENC(D3D12 零拷贝)与
+A 卡的 Media Foundation 硬件 MFT,与视频导出同一条路径、同一套能力边界:
+
+- HDR 输出固定使用 HEVC Main10(H.264 不接受 10bit),与导出一致;
+- 非 N 卡的 HDR 会被明确拒绝(系统编码器只有 8bit),不会偷偷降级成 SDR。
+
+**没有另写一套编码逻辑**,也没有引入新的运行库。
+
+### 2.3 不卡播放:写文件不在播放线程
+
+编码器在实时线程上工作(它需要增强图的纹理),但**容器写入放在独立线程**:
+
+- 编码器回调把码流包放进**有界队列**(240 包,高水位 160);
+- 写文件线程负责 `avio_open` / `avformat_write_header` / `av_interleaved_write_frame` /
+ `av_write_trailer`;
+- 队列到高水位时**丢帧并计数**,而不是阻塞播放。磁盘慢只影响录制,不影响播放。
+
+另外给编码器增加了可配置的**排空超时**(`EncoderConfig::drainTimeoutMs`):导出可以等
+10 秒,录制只等 2 秒,避免慢 GPU 把播放卡在编码器后面。
+
+### 2.4 文件与封装
+
+- 容器 MP4,时间基 1/1000000,PTS 取自真实时钟,所以录出来的时长与节奏是对的;
+- 文件名 `Veyra-YYYYMMDD-HHMMSS.mp4`,目录在设置里选,默认「视频/Veyra」;
+- 颜色元数据按 HDR/SDR 分别写 BT.2020/PQ 或 BT.709。
+
+### 2.5 生命周期
+
+| 事件 | 行为 |
+| --- | --- |
+| 用户点录制 | 界面走 3 秒倒计时(动画),结束后向引擎发请求 |
+| 引擎收到请求 | 在引擎线程打开编码器与文件,开始录制 |
+| 播放中 | 每次呈现提交后编码这一帧 |
+| 用户停止 / 会话结束 / **设置变更(重建增强图)** | 关闭文件(写尾索引)并汇报路径 |
+| 编码器或写文件失败 | 关闭录制,界面给出明确原因 |
+
+**设置变更会结束录制**:增强图重建会换掉所有纹理,录制器注册的 NVENC 资源随之失效,
+所以必须先收尾再重建,并明确告诉用户,而不是产出一个头尾不匹配的文件。
+
+### 2.6 本版边界(明确不做)
+
+- **不含音频轨**:只录画面,本版不做音频混流。
+- 只出 MP4,不出 MKV。
+- 暂停时不继续写入新帧(文件时间轴因此有间隔),本版不做暂停段的重复帧填充。
+- 录制不改变播放节奏统计口径(UI 33ms / 250ms 节奏不变)。
+
+## 三、改动清单
+
+| 文件 | 改动 |
+| --- | --- |
+| `include/veyra/engine/LiveRecorder.h`、`src/engine/LiveRecorder.cpp` | 新增:录制器(编码器 + 封装 + 写文件线程 + 有界队列) |
+| `include/veyra/sink/VideoEncoder.h` | `EncoderConfig` 增加 `drainTimeoutMs` |
+| `src/sink/NvencD3D12Encoder.cpp`、`src/sink/MfVideoEncoder.cpp` | 使用可配置排空超时 |
+| `include/veyra/engine/EngineController.h`、`src/engine/EngineController.cpp` | 录制请求/快照 API、呈现点编码钩子、重建与会话结束时收尾 |
+| `include/veyra/ui/QmlPlayerBridge.h`、`src/ui/QmlPlayerBridge.cpp` | 录制属性与方法、偏好项(位置/码率/帧率/编码)、轮询发布状态 |
+| `qml/Veyra/ProPage.qml` | 截图按钮旁的录制按钮:红点呼吸动画、3 秒倒计时与数字弹跳 |
+| `qml/Veyra/SettingsPage.qml` | 录制设置分区 |
+| `i18n/catalog.json` | 30 条新文案,四语齐备 |
+| `CMakeLists.txt` | 挂载 `src/engine/LiveRecorder.cpp` |
+
+## 四、验收
+
+1. 构建:`veyra_qml_ui` + QML 冒烟 + UI 契约 + 翻译检查目标通过;
+2. `i18n/extract.py --check` 无缺译、无占位符问题;
+3. QML 冒烟测试会真实实例化改过的 ProPage,语法或属性错误会直接失败;
+4. 打包成与 2.1.0 同一套运行组件的本地测试包(只换 EXE 与 QML,运行组件字节不动),
+ 冷启动验证通过后交付用户实测;
+5. **实卡录制效果、时长、画质与丢帧由用户实测确认**,本轮不宣称通过。
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index 09c7dfa1..750aa433 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -253,9 +253,9 @@ public:
// Live recording of the processed picture. The UI asks for it; the engine
// thread owns the encoder and the file, so the GPU resources stay on one
// thread and the playback loop keeps its cadence.
- void requestRecording(const RecordingOptions& options);
+ void requestRecording(const RecordingSettings& options);
void stopRecording();
- RecordingSnapshot recordingSnapshot()const;
+ RecordingStatus recordingSnapshot()const;
private:
void run(HWND,std::wstring,PlayerOptions,std::shared_ptr<source::RemotePlayConnectDesc> remoteRequest={},std::shared_ptr<source::MoonlightConnectDesc> moonlightRequest={},std::shared_ptr<source::XboxConnectDesc> xboxRequest={});
void runLargeImage(HWND,const sink::RgbaImage&,PlayerOptions,gfx::D3D12DeviceContext&,gfx::CommandSlotRing&);
@@ -293,9 +293,9 @@ private:
// Live recorder: the request comes from the UI thread, the encoder and the
// file belong to the engine thread.
std::unique_ptr<LiveRecorder> recorder_; // engine thread
- std::optional<RecordingOptions> recordingRequest_; // mutex_
+ std::optional<RecordingSettings> recordingRequest_; // mutex_
bool recordingStop_=false; // mutex_
- RecordingSnapshot recordingSnapshot_; // mutex_
+ RecordingStatus recordingStatus_; // mutex_
std::thread worker_;
std::unique_ptr<PreviewGpuSession> prewarmed_; // engine dispatcher only
std::atomic<bool> prewarmEnabled_{false}; // off until the saved preference enables it (default off since 2026-10-05)
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 0e09c8d6..69b66379 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -678,6 +678,15 @@ VPage {
}
}
}
+ NumberAnimation {
+ id: recordPop
+ target: recordLabel
+ property: "scale"
+ from: 1.18
+ to: 1.0
+ duration: Theme.d(Theme.durFast)
+ easing.type: Theme.spring
+ }
Timer {
id: recordTick
interval: 1000
@@ -693,15 +702,6 @@ VPage {
}
}
}
- NumberAnimation {
- id: recordPop
- target: recordLabel
- property: "scale"
- from: 1.18
- to: 1.0
- duration: Theme.d(Theme.durFast)
- easing.type: Theme.spring
- }
VButton {
id: presetBtn
iconName: "layers"
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index aca90910..f0c4e767 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -366,7 +366,7 @@ bool EngineController::requestSettings(EnhancementSettings s,std::optional<Chain
if(acceptedRevision)*acceptedRevision=s.revision;return true;
}
void EngineController::saveFrame(const std::wstring& path){std::lock_guard lock(mutex_);savePath_=path;}
-void EngineController::requestRecording(const RecordingOptions& options){
+void EngineController::requestRecording(const RecordingSettings& options){
// The UI thread only records the request; the engine thread owns the
// encoder, the GPU resources and the file.
{std::lock_guard lock(mutex_);recordingRequest_=options;}
@@ -374,15 +374,15 @@ void EngineController::requestRecording(const RecordingOptions& options){
}
void EngineController::stopRecording(){std::lock_guard lock(mutex_);recordingStop_=true;}
void EngineController::publishRecordingStatus(){
- if(!recorder_){std::lock_guard lock(mutex_);recordingSnapshot_={};return;}
+ if(!recorder_){std::lock_guard lock(mutex_);recordingStatus_={};return;}
const auto live=recorder_->status();
std::lock_guard lock(mutex_);
- recordingSnapshot_.active=live.active;recordingSnapshot_.failed=live.failed;
- recordingSnapshot_.path=live.path;recordingSnapshot_.error=live.error;
- recordingSnapshot_.encoder=live.encoder;recordingSnapshot_.frames=live.frames;
- recordingSnapshot_.dropped=live.dropped;recordingSnapshot_.seconds=live.seconds;
+ recordingStatus_.active=live.active;recordingStatus_.failed=live.failed;
+ recordingStatus_.path=live.path;recordingStatus_.error=live.error;
+ recordingStatus_.encoder=live.encoder;recordingStatus_.frames=live.frames;
+ recordingStatus_.dropped=live.dropped;recordingStatus_.seconds=live.seconds;
}
-RecordingSnapshot EngineController::recordingSnapshot()const{std::lock_guard lock(mutex_);return recordingSnapshot_;}
+RecordingStatus EngineController::recordingSnapshot()const{std::lock_guard lock(mutex_);return recordingStatus_;}
void EngineController::startExport(const std::wstring& input,const std::wstring& output,PlayerOptions opts,bool hevc){
if(opts.nodeOrder){
veyra::log::warn("node-order","export has no runtime node-order transport; request rejected before posting");
@@ -1203,7 +1203,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
OnExit resetExit{[&]{finishReset(stop_?diagnostics::ResetOutcome::Cancelled:diagnostics::ResetOutcome::Failed);
// The session owns the recorder: close the file on every exit
// path so the container is finalized.
- if(recorder_&&recorder_->active()){recorder_->end();publishRecordingStatus();}};
+ if(recorder_&&recorder_->active()){recorder_->end();publishRecordingStatus();}}};
auto collectTimings=[&]{
auto record=[&](const diagnostics::GpuFrameTiming& sample){
const auto& fgCost=sample.gpu[size_t(diagnostics::GpuStage::FgBatch)];
@@ -1562,7 +1562,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// Recording requests arrive from the UI thread; the encoder
// belongs to this thread, which owns the GPU context.
{
- std::optional<RecordingOptions> request;bool stop=false;
+ std::optional<RecordingSettings> request;bool stop=false;
{std::lock_guard lock(mutex_);request=recordingRequest_;recordingRequest_.reset();stop=recordingStop_;recordingStop_=false;}
if(stop&&recorder_&&recorder_->active()){recorder_->end();publishRecordingStatus();status(L"录制已结束",false);}
if(request){
diff --git a/src/engine/LiveRecorder.cpp b/src/engine/LiveRecorder.cpp
index 60d060fe..5dd53251 100644
--- a/src/engine/LiveRecorder.cpp
+++ b/src/engine/LiveRecorder.cpp
@@ -90,8 +90,7 @@ struct LiveRecorder::Impl {
std::lock_guard lock(statusMutex);
if (error.empty()) error = reason;
}
- veyra::log::error("live-recorder", std::format("writer failed: {}",
- std::string(error.begin(), error.end())));
+ veyra::log::error("live-recorder", std::format("writer failed: {}", utf8(error)));
}
bool writePacket(const Packet& packet) {
@@ -120,8 +119,7 @@ struct LiveRecorder::Impl {
return;
}
headerWritten.store(true, std::memory_order_relaxed);
- veyra::log::info("live-recorder", std::format("container header written path={}",
- std::string(utf8(path).begin(), utf8(path).end())));
+ veyra::log::info("live-recorder", std::format("container header written path={}", utf8(path)));
for (;;) {
Packet packet;
{
@@ -251,9 +249,8 @@ bool LiveRecorder::begin(gfx::D3D12DeviceContext& ctx, gfx::CommandSlotRing& rin
state_.store(State::Recording, std::memory_order_release);
veyra::log::info("live-recorder", std::format(
"started path={} extent={}x{} codec={} hdr={} fps={} bitrateMbps={} encoder={}",
- std::string(utf8(file).begin(), utf8(file).end()), p.width, p.height, p.hevc ? "HEVC" : "H264",
- p.hdr ? 1 : 0, p.fps, settings.bitrateMbps,
- std::string(utf8(p.encoderName).begin(), utf8(p.encoderName).end())));
+ utf8(file), p.width, p.height, p.hevc ? "HEVC" : "H264",
+ p.hdr ? 1 : 0, p.fps, settings.bitrateMbps, utf8(p.encoderName)));
return true;
}
@@ -319,7 +316,7 @@ void LiveRecorder::end() {
state_.store(failed ? State::Failed : State::Idle, std::memory_order_release);
veyra::log::info("live-recorder", std::format(
"stopped path={} frames={} dropped={} seconds={:.2f} failed={}",
- std::string(utf8(p.path).begin(), utf8(p.path).end()), p.frames.load(), p.dropped.load(),
+ utf8(p.path), p.frames.load(), p.dropped.load(),
double(p.recordedUs.load()) / 1000000.0, failed ? 1 : 0));
}
diff --git a/src/sink/NvencD3D12Encoder.cpp b/src/sink/NvencD3D12Encoder.cpp
index 509e4607..40db2666 100644
--- a/src/sink/NvencD3D12Encoder.cpp
+++ b/src/sink/NvencD3D12Encoder.cpp
@@ -33,7 +33,7 @@ struct NvencD3D12Encoder::Impl {
if(code!=NV_ENC_SUCCESS||successLogs<24||veyra::log::verboseFrameLogs()){if(code==NV_ENC_SUCCESS)++successLogs;veyra::log::info("nvenc",std::format("{} status={} detail={}",op,int(code),detail));}if(code!=NV_ENC_SUCCESS){const auto text=std::format("{} status={} {}",op,int(code),detail);error.assign(text.begin(),text.end());}return code==NV_ENC_SUCCESS;}
bool drain(Slot& s){
if(!s.pending)return true;
- if(fence->GetCompletedValue()<s.value){if(FAILED(fence->SetEventOnCompletion(s.value,event))||WaitForSingleObject(event,p.drainTimeoutMs)!=WAIT_OBJECT_0)return false;}
+ if(fence->GetCompletedValue()<s.value){if(FAILED(fence->SetEventOnCompletion(s.value,event))||WaitForSingleObject(event,drainTimeoutMs)!=WAIT_OBJECT_0)return false;}
NV_ENC_LOCK_BITSTREAM lock{};lock.version=NV_ENC_LOCK_BITSTREAM_VER;lock.outputBitstream=&s.out;lock.doNotWait=0;
if(!check(api.nvEncLockBitstream(encoder,&lock),"LockBitstream"))return false;
const bool ok=writer(static_cast<uint8_t*>(lock.bitstreamBufferPtr),lock.bitstreamSizeInBytes,static_cast<int64_t>(lock.outputTimeStamp),lock.pictureType==NV_ENC_PIC_TYPE_IDR);
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index a4a47ecb..d1617696 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -7256,7 +7256,7 @@ QVariantMap QmlPlayerBridge::recordingState() const { return impl_->recordingSta
void QmlPlayerBridge::startRecording() {
if (recording()) { emit notice(tr("录制已在进行中"), true); return; }
if (!hasSource()) { emit notice(tr("没有正在播放的画面,无法录制"), true); return; }
- engine::RecordingOptions options;
+ engine::RecordingSettings options;
options.directory = wideOf(recordingDirectory());
options.bitrateMbps = uint32_t(recordingBitrateMbps());
options.hevc = recordingHevc();