commit b244a530071d5ce672475c14f0889eacec4ff288
parent df0d898c0c4f45606a1cc864e9988465ff1a119e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 4 Oct 2026 16:13:56 -0400
common: video_720 gains codec-agnostic rungs at or under 720p before the last resort
After the H.264 720/480 rungs, bv*[height<=720]+ba and b[height<=720], so
a source whose only video at or under 720p is VP9 or AV1 stays at or under
720p. The last-resort log now fires only when nothing at or under 720p
exists.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/common/ytdlp/downloadFormat.test.ts b/common/ytdlp/downloadFormat.test.ts
@@ -30,12 +30,12 @@ test("clipFormatSelector is the selector umtool uses, and the old import path st
assert.equal(reexported, clipFormatSelector);
});
-test("video_720: the 720 rungs, then the 480 rungs, then the last resort", () => {
+test("video_720: the H.264 720 rungs, the 480 rungs, any codec at or under 720, then the last resort", () => {
assert.equal(VIDEO_720_PRESET, "video_720");
assert.ok(isDownloadFormatPreset("video_720"));
assert.ok(DOWNLOAD_FORMAT_PRESETS.includes("video_720"));
assert.equal(DOWNLOAD_FORMAT_LABELS.video_720, "Video 720p (H.264, for clips/editing)");
- const expected = `${CLIP_720}/${CLIP_480}/bv*+ba/b`;
+ const expected = `${CLIP_720}/${CLIP_480}/bv*[height<=720]+ba/b[height<=720]/bv*+ba/b`;
assert.equal(resolveDownloadFormatSelector("video_720", null), expected);
// An explicit preset ignores the platform, as every explicit preset does.
assert.equal(resolveDownloadFormatSelector("video_720", "odysee"), expected);
diff --git a/common/ytdlp/downloadFormat.ts b/common/ytdlp/downloadFormat.ts
@@ -71,9 +71,17 @@ export function clipFormatSelector(maxHeight: number): string {
export const VIDEO_720_MAX_HEIGHT = 720;
export const VIDEO_720_FALLBACK_HEIGHT = 480;
+// The codec-agnostic rungs of "video_720", after the H.264 ones: a source
+// whose only video at or under 720p is VP9 or AV1 still lands at or under 720p
+// rather than falling through to the best (possibly 4K) file.
+export const VIDEO_720_ANY_CODEC_RUNGS = [
+ `bv*[height<=${VIDEO_720_MAX_HEIGHT}]+ba`,
+ `b[height<=${VIDEO_720_MAX_HEIGHT}]`,
+] as const;
+
// The last rung of "video_720": anything at all. Reached only when the source
-// has nothing the 720 and 480 rungs accept, so a file above 720p is possible —
-// the download logs it (downloadOneManaged, logPersistedFormat) rather than
+// has nothing at or under 720p, so a file above 720p is possible — the
+// download logs it (downloadOneManaged, persistedFormatLog) rather than
// letting it pass silently.
export const LAST_RESORT_FORMAT_SELECTOR = "bv*+ba/b";
@@ -98,6 +106,7 @@ export function resolveDownloadFormatSelector(
return [
clipFormatSelector(VIDEO_720_MAX_HEIGHT),
clipFormatSelector(VIDEO_720_FALLBACK_HEIGHT),
+ ...VIDEO_720_ANY_CODEC_RUNGS,
LAST_RESORT_FORMAT_SELECTOR,
].join("/");
case "auto":
diff --git a/common/ytdlp/downloadOneManaged.ts b/common/ytdlp/downloadOneManaged.ts
@@ -280,7 +280,7 @@ export function persistedFormatLog(
) {
return (
`Source quality ${VIDEO_720_PRESET}: no format at or under ${VIDEO_720_MAX_HEIGHT}p matched ` +
- `the 720p/480p rungs; the last resort (${LAST_RESORT_FORMAT_SELECTOR}) took ${what}.\n`
+ `any rung; the last resort (${LAST_RESORT_FORMAT_SELECTOR}) took ${what}.\n`
);
}
return `Source format: ${what} (quality ${format.preset}).\n`;
diff --git a/common/ytdlp/persistFormatPreset.test.ts b/common/ytdlp/persistFormatPreset.test.ts
@@ -178,7 +178,7 @@ test("video_720 answered by the last resort: a file above 720p is logged, not si
try {
assert.match(
r.log,
- /Source quality video_720: no format at or under 720p matched the 720p\/480p rungs; the last resort \(bv\*\+ba\/b\) took 1080p vp9 \(format 248\+251\)\.\n/,
+ /Source quality video_720: no format at or under 720p matched any rung; the last resort \(bv\*\+ba\/b\) took 1080p vp9 \(format 248\+251\)\.\n/,
);
assert.deepEqual(r.pointer.format, { preset: "video_720", height: 1080, vcodec: "vp9" });
} finally {