Fetch YouTube at up to 1080p instead of 360p

YouTube's only muxed mp4 is format 18 (360p), so the muxed-first selector
was posting 360p even when 1080p was available. Split streams are now
preferred for YouTube and merged locally; every other host keeps the
muxed-first chain unchanged (verified identical selection for Instagram,
X and Reddit).

Three things the obvious version got wrong:

- A height<=1080 cap excludes portrait video: a 1080p Short or reel is
  1080x1920. Resolution is capped with -S res:1080 instead, which keys
  off the smaller dimension.

- h264 is a hard first preference, not an -S sort key. At equal
  resolution YouTube's VP9/AV1 renditions are smaller and win on size,
  but neither reliably plays in an mp4 container on older Signal
  clients. Dropping a resolution rung to stay on h264 is the better
  trade, and is usually smaller too: a 10-min video takes 480p h264
  (37 MB) over 720p AV1 (78 MB).

- The audio cap matters. YouTube's 388k track is 29 MB by itself on a
  10-min video, enough to push an otherwise-fine merge past the 100 MB
  Signal limit; abr<=160 takes the 129k track instead.

The 88 MB video cap makes yt-dlp step down automatically on long videos,
so a 3-min video lands at 1080p (80 MB) and a 10-min one at 480p.

Clips get the same treatment — they're YouTube-only, and 60s at 1080p is
only ~29 MB. /force is deliberately left muxed-first: it exists for the
biggest, slowest videos, where 1080p would risk the rsync timeout.

Measured, old -> new: 3-min 360p/11 MB -> 1080p/80 MB; 10-min 360p/27 MB
-> 480p/37 MB; portrait Short 360x640/6 MB -> 1080x1920/23 MB. Verified
end to end: real downloads decode as h264+aac, clip lands at exactly
60.000s.
This commit is contained in:
2026-08-14 14:30:11 -04:00
parent 3e3aba4157
commit 1523bdd48d
2 changed files with 66 additions and 19 deletions
+4 -1
View File
@@ -8,7 +8,10 @@ couple of toys for messing with the last video.
- **Auto-download** — watches every group message for a supported link and
replies with the video. Powered by [yt-dlp](https://github.com/yt-dlp/yt-dlp).
Videos over 100 MB are auto re-encoded with ffmpeg to fit.
Videos over 100 MB are auto re-encoded with ffmpeg to fit. YouTube is fetched
as h264 up to 1080p, stepping down a resolution rung on longer videos so the
merge lands under the Signal size limit without a re-encode; other hosts take
their muxed rendition as-is.
- **`/speed [n]`** — re-posts the last video sped up `n`× (default 2×), pitch-shifted
like tape. e.g. `/speed 4`, `/speed 0.5`.
- **`/rev`** — re-posts the last video reversed (audio too).