Repository navigation
fix(media-server): Cap Infra posters up to 1920 on the long side - #4209
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 1 credit · Review details |
Member
Author
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Cap Infra posters were capped at 1280x720 because both Infra encode paths used the regular thumbnail defaults. They are now produced at up to 1920 on the long side, keeping the aspect ratio and never upscaling. Regular Cap thumbnails are unchanged.
What changed
src/lib/infra-poster.ts:posterThumbnailOptions(infra)returns a 1920x1920 box for an Infra job and{}for everything else.src/routes/video.ts: two call sites now passposterThumbnailOptions(options.infra)instead of{}:/video/ladderposter, taken from the top rendition;/video/processthumbnail./video/processmatters because each Infra encode part writes its own poster, and the video keeps whichever part finishes first. Without it, an MP4 part that finished first would still leave a 1280x720 poster.infra: true. Regular Cap, the Loom importer, mux, edit and/video/thumbnaileither don't send it or don't reach this code, so they keep{}.DEFAULT_THUMBNAIL_OPTIONSis untouched.Resulting sizes: a 16:9 top rendition at 1080p or above gives 1920x1080, a 9:16 one gives 1080x1920, and anything smaller than the box keeps its own size.
Measurements
Poster generation through
generateThumbnail, on the top rendition as the ladder uses it. Run on an L4 test machine with the production image's FFmpeg 7.1.5, median of 9 runs:On an M-series Mac with FFmpeg 8: 4K text took 114 to 124 ms before and 113 to 151 ms after, and 1080p text took 49 ms before and 54 to 56 ms after.
Ready time: the poster renders while the renditions upload (and while the MP4 uploads in
/video/process), so it isn't on the critical path. The worst measured cost is +7 ms on a 1080p source. Whole/video/ladderjobs with a local upload sink, 15 interleaved runs each on the Mac: 4K median 7327 ms before vs 7556 ms after, and 1080p 1466 ms before vs 1394 ms after. Round-to-round drift was larger than either difference.Tests
src/__tests__/lib/infra-poster.integration.test.ts, added to bothDockerfileandDockerfile.standalone, so it runs on the image's own FFmpeg. It spies ongenerateThumbnailat the real call sites:/video/processjob passes exactly{}and uploads a 1280x720 poster from a 2560x1440 source;/video/processjob passes the 1920 box and uploads 1920x1080;/video/ladderat 1440p uploads 1920x1080;hls-ladder-route7,routes/video38,media-routes-real-world45,hls-ladder68,infra-capacity9.Not in this PR: ladder bitrate order
Under constant quality, a lower rung can come out at a higher bitrate than the rung above it. This is deferred to a two-pass design after launch. The hosted player already ranks renditions by height, not BANDWIDTH, so the inversion wastes some bandwidth but never picks the wrong quality.
Root cause. Text content costs more bits when it is downscaled. A pristine 1080p text render encodes at 594k (libx264 CRF 23), while its 720p downscale costs about 2000k with any scaler (lanczos 2020k, bicubic 1841k, area 1831k). Natural content goes the other way. So the order depends on content and can't be predicted before encoding.
Repro with the current ladder args on the production image's FFmpeg 7.1.5 + NVENC (L4), 15 s synthetic clips, average kbps:
libx264 shows the same: on the 1080p text clip, 1080p comes out at 735k and 720p at 2022k.
Options measured:


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Infra posters now fit within 1920×1920 in both encode paths. Regular thumbnails keep their existing defaults.
Acknowledgment:
richiemcilroyexplicitly deferred ladder bitrate ordering to a two-pass design after launch. This PR does not change that behavior.Reviews (1) · Last reviewed commit: "test(media-server): run the Infra poster..." · Reviewed by Greptile