fix(video): populate NTV2 fileInfo.time with the real duration (receiver was rendering 00:00)
The NTV2 upload request for video carried `time: 0` on the main mp4 sub-file, mirroring NapCat's transformer. But NapCat lives on top of the desktop QQ-NT client's IPC layer, which patches the duration into the resulting MsgInfo before the wire send — we don't have that layer, so the `time: 0` we passed in ended up baked into the `VideoFile. fileTime` field of every video the bot sent. Receivers then rendered every video bubble as "00:00". Cross-checked acidify's `RichMediaUpload.kt::buildVideoUploadInfoList` (2026-04 refactor) — they're a protocol-direct client too and write `time = payload.videoDuration` for exactly this reason. We already have `video.duration` from `loadVideo` (probed via ffprobe), so it's a one-liner. Width/height kept at 0 deliberately — acidify fills them, NapCat zeros them, and our earlier comment recorded "QQ NT server treats non-zero values here as schema mismatch on c2c sends". Out of scope for this fix; revisit if a c2c regression surfaces. Test asserts `fileInfo.time === 10` for the main sub-file (matches FINGERPRINT.duration) and stays 0 on the thumb.
This commit is contained in:
2 files changed
+30
-5
No files matched your search
@@ -90,6 +90,21 @@ describe('video-upload', () => {
|
||||
expect((uploadInfo[1] as any).fileInfo.type.type).toBe(1); // pic (thumb)
|
||||
});
|
||||
|
||||
it('main video carries the real `time` (duration in seconds) — regression: was 0', async () => {
|
||||
// NTV2 server bakes the `time` field into the resulting MsgInfo
|
||||
// bytes that ride along as `commonElem.pbElem`; the receiver
|
||||
// reads it back via `VideoFile.fileTime` and renders it as the
|
||||
// playable duration. NapCat ships `time: 0` only because it sits
|
||||
// on top of QQ-NT's IPC layer which patches the value in before
|
||||
// the wire send; we're a protocol-direct client (same position
|
||||
// as acidify) and must populate it ourselves. Without this the
|
||||
// receiver shows "00:00" on every video the bot sends.
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, FINGERPRINT);
|
||||
const uploadInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((uploadInfo[0] as any).fileInfo.time).toBe(10); // matches FINGERPRINT.duration
|
||||
expect((uploadInfo[1] as any).fileInfo.time).toBe(0); // thumb stays at 0 (matches acidify)
|
||||
});
|
||||
|
||||
it('thumb falls back to a synthesized 1x1 PNG with real bytes', async () => {
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, FINGERPRINT);
|
||||
const uploads = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploads;
|
||||
|
||||
Reference in new issue
Block a user