feat(video): raise video-path size limit to 1.5 GiB (#145)

The 100 MB cap that re-routed larger videos to the file-upload pipeline
was a workaround for the width/height=0 → 已过期 bug (fixed in the prior
commit), not a real QQ size limit. Real-machine verified on tempserver:
88 MB / 149 MB / 299 MB / 497 MB videos all upload, render and play as
normal videos in a group. Raise MAX_VIDEO_SIZE to 1.5 GiB (matching the
file-upload ceiling); only videos above that still fall back to the file
path. Collapse the redundant MAX_VIDEO_SIZE_HARD (was also 1.5 GiB) into
the single constant and drop the now-dead 100 MB warn branches.

Note: the whole video is buffered in RAM for the Highway upload, so a
1.5 GiB send costs ~1.5 GiB+ of process memory — that, not a QQ limit,
is what bounds the ceiling.
This commit is contained in:
DrSmoothl committed 2026-07-04 23:45:36 +08:00
1 parent 9a6c17cb27
commit c236bc86ee
3 files changed
+27 -24

No files matched your search

@@ -620,11 +620,12 @@ export async function sendPrivateMessage(
let allFileElements = elements.filter(e => e.type === 'file');
let nonFileElements = elements.filter(e => e.type !== 'file');
// [#145] A video above QQ's ~100 MB video-resource cap (MAX_VIDEO_SIZE)
// uploads "successfully" but renders as 视频已过期 on the receiver — the
// server accepts the bytes yet never produces a valid video resource. The
// on-error fallback below can't catch it (the oversized upload doesn't
// throw), so route known-oversized videos to the file path up front.
// [#145] Videos up to MAX_VIDEO_SIZE (1.5 GiB) send as real videos; only
// above that do we route to the file pipeline (the whole video is buffered
// in RAM for the Highway upload, so this bounds memory). The earlier
// 100 MB cap was a workaround for the width/height=0 → 已过期 bug (now
// fixed) and has been lifted. Route known-oversized videos up front —
// the on-error fallback below can't catch them (the upload doesn't throw).
{
const pre = splitVideoFileFallback(nonFileElements, false);
if (pre.fileEls.length > 0) {
@@ -723,8 +724,8 @@ export async function sendGroupMessage(
let allFileElements = elements.filter(e => e.type === 'file');
let nonFileElements = elements.filter(e => e.type !== 'file');
// [#145] Route known-oversized videos (> MAX_VIDEO_SIZE) to the file path
// up front — they upload as a video without error but render expired.
// [#145] Route videos above MAX_VIDEO_SIZE (1.5 GiB) to the file path up
// front; everything at or below sends as a real video (see sendPrivate).
{
const pre = splitVideoFileFallback(nonFileElements, false);
if (pre.fileEls.length > 0) {
@@ -96,15 +96,17 @@ describe('send_group_msg large-video fallback', () => {
describe('videoNeedsFileFallback', () => {
it('triggers on a known oversize source regardless of the error message', () => {
// The real-bot case: a local 1.4 GB video whose Highway upload fails
// with a cryptic `error_code=323` (not size-worded). Source size is
// known, so the file fallback must still fire.
const big = { type: 'video', fileSize: 1400 * MB } as MessageElement;
// Above MAX_VIDEO_SIZE (1.5 GiB) the video is re-routed to the file
// pipeline even when the error isn't size-worded. Source size is known,
// so the fallback fires from the size alone.
const big = { type: 'video', fileSize: 1700 * MB } as MessageElement;
expect(videoNeedsFileFallback(big, /* isSizeErr */ false)).toBe(true);
});
it('does not trigger for a known under-limit source', () => {
const small = { type: 'video', fileSize: 50 * MB } as MessageElement;
it('does not trigger for a known under-limit source (now covers large videos)', () => {
// 500 MB used to route to file under the old 100 MB cap; it now sends as
// a real video (verified on tempserver up to ~500 MB).
const small = { type: 'video', fileSize: 500 * MB } as MessageElement;
expect(videoNeedsFileFallback(small, true)).toBe(false);
});