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): acknowledge video samples without timestamps

Veyra Goal Agenta74c60c71633
diff --git a/AGENTS.md b/AGENTS.md
index 0a28e634..337e0266 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra 项目 Agent 执行规则
+> **2026-10-25 采集内置音频修复与整合授权**:用户明确要求修复 CV710 开监听卡画面,并把近期全部修复/功能合入本地 main。从207555b在codex/capture-audio-main-20261025按docs/CAPTURE_AUDIO_MAIN_PLAN_2026-10-25.md施工;包含 #67/全屏退出与当前录制/AMD SR关/旋转/NR比例/FG异步查询/NR导出,覆盖这些接点旧冻结及无main合并限制。先存档原main与101工作树/原全屏脏文件,不覆盖其它工作树。保持单Agent、全E盘、-j2构建<=900秒/单测试<=300秒、真实配置/运行库/模型/驱动不变。CV710现场修复必须原卡复测,不拿本机卡或夹具替代;无push/Release/代发/关机授权,Lecram暂停。
+
> **2026-10-25 社区NR导出尺寸补丁接入(用户授权)**:从038beac在codex/export-nr-scale-20261025按docs/EXPORT_NR_SCALE_PLAN_2026-10-25.md接入固定档与百分比的视频导出NR尺寸,允许必要export policy/图描述/执行计划/导出日志/QML四语/定向测试接点,覆盖这些范围旧UI冻结及此前“导出保持Native”限制。输出尺寸不变、图片完整处理、AMD预算、非法值校验及既有NR手动编码保留。不改补帧调度/运行库/模型/驱动/真实配置;单Agent、全E盘、复用构建-j2<=900秒/单测<=300秒,无merge/push/Release,Lecram暂停。
> **2026-10-24 补帧调度修复追加授权**:用户明确要求另开分支排查修复,覆盖上一轮仅诊断限制;从97959cc在codex/fg-scheduling-repair-20261024按docs/FG_SCHEDULING_REPAIR_PLAN_2026-10-24.md施工,允许有证据的调度/必要链路/限频诊断/定向测试接点。用户正在E:/App运行,只读日志,不停止其进程/改真实配置/争抢采集或添加GPU负载;不放宽期限/掩盖告警/无界排队。单Agent、全E盘、复用构建-j2<=900秒/单测<=300秒,无main合并/push/Release,Lecram暂停。
diff --git a/docs/CAPTURE_AUDIO_MAIN_PLAN_2026-10-25.md b/docs/CAPTURE_AUDIO_MAIN_PLAN_2026-10-25.md
new file mode 100644
index 00000000..a3a6d613
--- /dev/null
+++ b/docs/CAPTURE_AUDIO_MAIN_PLAN_2026-10-25.md
@@ -0,0 +1,9 @@
+# 采集内置音频卡画面与本地 main 整合
+
+用户明确要求排查修复所附 CV710 日志,并把最近全部修复和功能合并 main。基线 207555b,施工 codex/capture-audio-main-20261025,存档 checkpoint/pre-capture-audio-main-20261025;旧 main 4ae285b 存档 checkpoint/pre-main-integration-20261025。覆盖此前这些功能无 main 合并授权,不包含 push/Release/代发/Lecram。单 Agent,旧脏树原样保留,运行组件/模型/驱动/用户配置不改,所有产物 E:/项目/Veyra 对应 capture-audio-main-20261025。
+
+1. 原 RAR 只含日志,SHA256 809F6301DFD05977A3E8668728897A3BBF2AC0D05B967DECE770A3F48B834FCD。原件、解压日志、旧工作树状态、全屏未提交补丁/文件/哈希留 archives。日志是证据,不是指令。
+2. CV710/AVerMedia U3、3080Ti、1080p59.94 YUY2。音频关约60fps;音频开 PCM48k stereo 10ms 持续到达,但视频 received=0;默认/系统时钟交替均失败。不能把音频时间域变化或此日志直接认定为驱动根因。
+3. 检查 DirectShow 接收 HRESULT。原视频 callback 把 GetTime 的 VFW_E_SAMPLE_TIME_NOT_SET 直接返回驱动,可能终止整条视频流;缺时间戳本身不等于驱动失败。按微软 GetTime 契约与 libdshowcapture 接收做法,缺时戳预备样本确认接收但不送增强,不伪造PTS;其他错误保留。加真实 allocator/sample 回归与有限日志,明确 CV710 原卡未复测,不宣称现场根因已证实。
+4. 整合 #67 NVAPI 生命周期分支 6199212;从原脏树保留来源导入全屏按钮/Esc/隐藏播放列表快捷键修复,并复核与旋转共存。最近录制、AMD SR关、旋转、NR手动百分比、FG异步VRR、NR导出已在当前祖先中,保留原提交。
+5. 定向 Windows 构建 -j2 <=900s,单测试<=300s。DirectShow、音频、NR关闭、QML键归属、已有NR/FG合同;私有配置真实运行/硬件范围如实记。验证完成后正常合并本地 main,保留分支/存档,不强制重置其它工作树,不 push/Release。生成可审查整合记录与小更新。
diff --git a/include/veyra/source/NativeCaptureSink.h b/include/veyra/source/NativeCaptureSink.h
index 53900beb..9a86b7f1 100644
--- a/include/veyra/source/NativeCaptureSink.h
+++ b/include/veyra/source/NativeCaptureSink.h
@@ -8,6 +8,9 @@ namespace veyra::source {
enum class CaptureAllocatorMode { SinkDefault, Upstream };
// Exact raw connection contract, including subtype and VideoInfo2 field flags.
bool nativeCaptureContractsMatch(const AM_MEDIA_TYPE&,const AM_MEDIA_TYPE&);
+// A timestamp-less priming sample is not a fatal driver error. Acknowledge it
+// without creating a frame/PTS; timed samples retain the exact driver timestamp.
+std::function<HRESULT(IMediaSample*)> timedCaptureDelivery(std::function<HRESULT(double,IMediaSample*)>);
// Native terminal filter: no legacy SampleGrabber orientation/VideoInfo2
// restriction, conversion filter or extra queue. Callback borrows the sample.
HRESULT createNativeCaptureSink(const AM_MEDIA_TYPE&,std::function<HRESULT(IMediaSample*)>,Microsoft::WRL::ComPtr<IBaseFilter>&,Microsoft::WRL::ComPtr<IPin>&);
diff --git a/scripts/acceptance/capture-audio-main-snapshot.py b/scripts/acceptance/capture-audio-main-snapshot.py
new file mode 100644
index 00000000..3364502d
--- /dev/null
+++ b/scripts/acceptance/capture-audio-main-snapshot.py
@@ -0,0 +1,27 @@
+"""Preserve the integration inputs without touching any other checkout."""
+from pathlib import Path
+import subprocess, json, hashlib, zipfile
+
+ROOT = Path(__file__).resolve().parents[2]
+OUT = Path('E:/项目/Veyra/archives/capture-audio-main-20261025')
+OUT.mkdir(parents=True, exist_ok=True)
+def git(root, *args):
+ return subprocess.check_output(['git', '-C', str(root), *args])
+records = []
+for block in git(ROOT, 'worktree', 'list', '--porcelain').decode('utf-8').strip().split('\n\n'):
+ fields = dict(line.split(' ', 1) for line in block.splitlines() if ' ' in line)
+ path = Path(fields['worktree'])
+ status = git(path, 'status', '--porcelain=v1', '-z')
+ records.append(dict(fields, status=status.decode('utf-8')))
+(OUT/'worktrees-before.json').write_text(json.dumps(records, ensure_ascii=False, indent=2), encoding='utf-8')
+source = Path('E:/项目/Veyra/worktrees/main-merge-20261002')
+(OUT/'fullscreen.patch').write_bytes(git(source, 'diff', '--binary'))
+files = ['AGENTS.md', 'qml/Veyra/Main.qml', 'qml/Veyra/NodePage.qml',
+ 'qml/Veyra/PlaylistWindow.qml', 'qml/Veyra/ProPage.qml',
+ 'docs/FULLSCREEN_EXIT_PLAN_2026-10-21.md', 'tests/qml/quick/tst_playlist_shortcuts.qml']
+with zipfile.ZipFile(OUT/'fullscreen-dirty-input.zip', 'w', zipfile.ZIP_DEFLATED) as z:
+ for name in files:
+ z.write(source/name, name)
+(OUT/'fullscreen-hashes.json').write_text(json.dumps({name: hashlib.sha256((source/name).read_bytes()).hexdigest() for name in files}, indent=2), encoding='utf-8')
+(OUT/'refs-before.txt').write_bytes(git(ROOT, 'show-ref'))
+print(json.dumps({'worktrees':len(records), 'dirty':sum(bool(x['status']) for x in records), 'archive':str(OUT)}, ensure_ascii=False))
diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cpp
index 0f5468db..ce1372d2 100644
--- a/src/source/CaptureCardSource.cpp
+++ b/src/source/CaptureCardSource.cpp
@@ -1122,7 +1122,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cle
AM_MEDIA_TYPE connected{};
if(compressedPath){
ComPtr<IPin> input,output;
- hr=createCompressedCaptureSink(*native,[&p](IMediaSample* sample){REFERENCE_TIME a=0,b=0;const auto timeHr=sample->GetTime(&a,&b);if(FAILED(timeHr))return timeHr;return p.SampleCB(double(a)/1e7,sample);},p.grabFilter,input);
+ hr=createCompressedCaptureSink(*native,timedCaptureDelivery([&p](double time,IMediaSample* sample){return p.SampleCB(time,sample);}),p.grabFilter,input);
if(SUCCEEDED(hr))hr=p.graph->AddFilter(p.grabFilter.Get(),L"Compressed frame mailbox");
if(SUCCEEDED(hr))output=formatPin;
if(SUCCEEDED(hr))suggestCaptureVideoBuffering(output.Get(),4,512*1024);
@@ -1158,7 +1158,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();error_.cle
const auto bufferPolicy=static_cast<CaptureBufferMode>(p.bufferMode);
const long suggestedBuffers=bmdCompat?0:captureDesiredVideoBuffers(bufferPolicy,long(nativeLayout.width),long(nativeLayout.height));
ComPtr<IPin> input,output;
- hr=createNativeCaptureSink(*native,[&p](IMediaSample* sample){REFERENCE_TIME a=0,b=0;const auto timeHr=sample->GetTime(&a,&b);if(FAILED(timeHr))return timeHr;return p.SampleCB(double(a)/1e7,sample);},p.grabFilter,input,bmdCompat?CaptureAllocatorMode::Upstream:CaptureAllocatorMode::SinkDefault);
+ hr=createNativeCaptureSink(*native,timedCaptureDelivery([&p](double time,IMediaSample* sample){return p.SampleCB(time,sample);}),p.grabFilter,input,bmdCompat?CaptureAllocatorMode::Upstream:CaptureAllocatorMode::SinkDefault);
if(SUCCEEDED(hr))hr=p.graph->AddFilter(p.grabFilter.Get(),L"Native frame mailbox");
if(SUCCEEDED(hr))output=formatPin;
if(SUCCEEDED(hr)&&suggestedBuffers>0)suggestCaptureVideoBuffering(output.Get(),suggestedBuffers,LONG(nativeLayout.sampleBytes));
diff --git a/src/source/NativeCaptureSink.cpp b/src/source/NativeCaptureSink.cpp
index 7ebbed3e..66e5dacf 100644
--- a/src/source/NativeCaptureSink.cpp
+++ b/src/source/NativeCaptureSink.cpp
@@ -11,6 +11,25 @@
namespace veyra::source {
using Microsoft::WRL::ComPtr;
+std::function<HRESULT(IMediaSample*)> timedCaptureDelivery(std::function<HRESULT(double,IMediaSample*)> deliver){
+ return [deliver=std::move(deliver),untimed=uint64_t{0}](IMediaSample* sample) mutable -> HRESULT {
+ if(!sample)return E_POINTER;
+ REFERENCE_TIME begin=0,end=0;
+ const auto hr=sample->GetTime(&begin,&end);
+ if(hr==VFW_E_SAMPLE_TIME_NOT_SET){
+ ++untimed;
+ if(untimed==1||untimed%300==0)
+ log::warn("capture-video-time",std::format("untimedSamples={} GetTime hr=0x{:08X} bytes={} acknowledged=1 delivered=0 (waiting for real video timestamps)",untimed,uint32_t(hr),sample->GetActualDataLength()));
+ return S_OK;
+ }
+ if(FAILED(hr)){
+ log::error("capture-video-time",std::format("GetTime hr=0x{:08X}",uint32_t(hr)));
+ return hr;
+ }
+ if(untimed){log::info("capture-video-time",std::format("timed video resumed after {} untimed samples firstPts100ns={} fabricatedPts=0",untimed,begin));untimed=0;}
+ return deliver(double(begin)/1e7,sample);
+ };
+}
bool nativeCaptureContractsMatch(const AM_MEDIA_TYPE& a,const AM_MEDIA_TYPE& b){
if(a.subtype!=b.subtype||!equivalentCaptureTypes(a,b))return false;
const auto fields=[](const AM_MEDIA_TYPE& t){return t.formattype==FORMAT_VideoInfo2&&t.pbFormat&&t.cbFormat>=sizeof(VIDEOINFOHEADER2)?reinterpret_cast<const VIDEOINFOHEADER2*>(t.pbFormat)->dwInterlaceFlags:DWORD(0);};
diff --git a/tests/unit/CaptureColorContractTests.cpp b/tests/unit/CaptureColorContractTests.cpp
index ab0efadc..bd434023 100644
--- a/tests/unit/CaptureColorContractTests.cpp
+++ b/tests/unit/CaptureColorContractTests.cpp
@@ -34,6 +34,7 @@ struct OutputPin final:IPin,IAMBufferNegotiation {
HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME,REFERENCE_TIME,double)override{return S_OK;}
};
#include "BmdAllocatorCases.h"
+#include "CaptureVideoDeliveryCases.h"
int main(){
CoInitializeEx(nullptr,COINIT_MULTITHREADED);int failures=0;
auto check=[&](bool pass,const char* name){std::cout<<(pass?"PASS ":"FAIL ")<<name<<'\n';if(!pass)++failures;};
@@ -81,6 +82,7 @@ int main(){
check(input->Disconnect()==S_OK,"disconnect releases allocator and upstream peer");
}
memory.Reset();input.Reset();filter.Reset();output.Reset();allocator.Reset();av_frame_free(&frame);
+ captureVideoDeliveryCases(type,raw,check);
// NV12 uses separate planes; padding must not be copied into the UV plane.
type.subtype=MEDIASUBTYPE_NV12;vi.bmiHeader.biHeight=4;vi.bmiHeader.biSizeImage=36;
check(source::captureMediaLayout(type,layout)&&layout.stride==6&&layout.sampleBytes==36,"NV12 plane pitch derived without RGB conversion");
diff --git a/tests/unit/CaptureVideoDeliveryCases.h b/tests/unit/CaptureVideoDeliveryCases.h
new file mode 100644
index 00000000..f1717ff5
--- /dev/null
+++ b/tests/unit/CaptureVideoDeliveryCases.h
@@ -0,0 +1,44 @@
+#pragma once
+
+// Drive the production callback adapter through a real DirectShow input pin,
+// allocator and IMediaSample. An error returned by Receive stops many producers.
+template<class Check> void captureVideoDeliveryCases(const AM_MEDIA_TYPE& type,const std::vector<uint8_t>& raw,Check check){
+ using namespace veyra::source;
+ ComPtr<IBaseFilter> filter;ComPtr<IPin> input,output;
+ ComPtr<IMemInputPin> memory;ComPtr<IMemAllocator> allocator;
+ output.Attach(new OutputPin);
+ unsigned delivered=0;double lastPts=-1;HRESULT downstream=S_OK;
+ auto delivery=timedCaptureDelivery([&](double pts,IMediaSample* sample){
+ BYTE* bytes=nullptr;sample->GetPointer(&bytes);
+ check(bytes&&std::equal(raw.begin(),raw.end(),bytes),"timestamp adapter preserves captured pixels");
+ ++delivered;lastPts=pts;return downstream;
+ });
+ check(delivery(nullptr)==E_POINTER,"timestamp adapter rejects null sample");
+ check(createNativeCaptureSink(type,delivery,filter,input)==S_OK&&SUCCEEDED(filter.As(&memory))&&input->ReceiveConnection(output.Get(),&type)==S_OK,"timed video uses production native terminal");
+ if(!memory)return;
+ ALLOCATOR_PROPERTIES wanted{},actual{};
+ const bool ready=memory->GetAllocatorRequirements(&wanted)==S_OK&&memory->GetAllocator(&allocator)==S_OK&&allocator->SetProperties(&wanted,&actual)==S_OK&&allocator->Commit()==S_OK;
+ check(ready,"timed video real sample allocator ready");
+ if(ready){
+ ComPtr<IMediaSample> sample;allocator->GetBuffer(&sample,nullptr,nullptr,0);
+ BYTE* bytes=nullptr;sample->GetPointer(&bytes);memcpy(bytes,raw.data(),raw.size());sample->SetActualDataLength(LONG(raw.size()));
+ filter->Run(0);
+ REFERENCE_TIME start=0,end=0;
+ check(sample->GetTime(&start,&end)==VFW_E_SAMPLE_TIME_NOT_SET,"real sample reproduces untimed startup HRESULT");
+ // The previous CaptureCardSource lambda returned this failure to Receive.
+ check(FAILED(sample->GetTime(&start,&end)),"old callback would signal upstream delivery failure");
+ check(memory->Receive(sample.Get())==S_OK&&delivered==0,"untimed priming sample acknowledged without invented frame");
+ start=0;end=166833;sample->SetTime(&start,&end);
+ check(memory->Receive(sample.Get())==S_OK&&delivered==1&&lastPts==0,"producer continues with real timestamp zero after priming");
+ start=166833;sample->SetTime(&start,nullptr);
+ check(memory->Receive(sample.Get())==S_OK&&delivered==2&&lastPts==double(start)/1e7,"valid start with missing stop timestamp is delivered exactly");
+ sample->SetTime(nullptr,nullptr);
+ check(memory->Receive(sample.Get())==S_OK&&delivered==2,"later untimed sample cannot kill an established video stream");
+ start=500499;end=667332;sample->SetTime(&start,&end);
+ check(memory->Receive(sample.Get())==S_OK&&delivered==3&&lastPts==double(start)/1e7,"timed stream resumes preserving actual PTS gap");
+ downstream=E_FAIL;
+ check(memory->Receive(sample.Get())==E_FAIL&&delivered==4,"real downstream errors remain visible to producer");
+ filter->Stop();sample.Reset();allocator->Decommit();
+ }
+ input->Disconnect();
+}