Repository navigation
feat: use the video's own cover instead of a grabbed frame - #34
Merged
Merged
Conversation
A film's poster and cover.jpg now come from the video itself: the picture its site gives it (job.Thumbnail), else the cover art its file carries. A frame is grabbed from the video only when it has neither. cover.jpg is rewritten whenever it holds something else, so libraries from an earlier Kando swap their grabbed frames for the site's picture the next time the shelf loads. Non-JPEG pictures (YouTube's WebP thumbnails, PNG cover art) are encoded as JPEG so cover.jpg stays a JPEG.
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.
Summary
Library cards, the hero and each film's
cover.jpgshowed a frame ffmpeg grabbed from the downloaded video, even though the site had already given the video a cover (it was used on the processing card and then replaced once the download finished). Posters now come from the video itself:job.Thumbnail, already saved in library.json). It is fetched once into the posters cache, which the processing card's thumbnail already uses, so a film that just finished downloading usually needs no new request.ffmpeg -map 0:v -map -0:V -c copy(newmedia.EmbeddedCover).cover.jpgit already has, or has a frame grabbed as before. This covers a site that no longer serves the picture (for example TikTok's signed thumbnail URLs expire) or a machine that is offline.cover.jpgis rewritten whenever its bytes differ from the video's own cover, so existing libraries swap their grabbed frames for the site's picture on the next load. The rewrite is idempotent and needs no new field in library.json. Non-JPEG pictures (YouTube's WebP thumbnails, PNG cover art) are re-encoded as JPEG socover.jpgstays a JPEG. That needs thegolang.org/x/image/webpdecoder, whichapps/kandoalready had as an indirect dependency through MyGo; go.mod only moves it to the direct block, at the same version v0.47.0.Screenshots
The hero of the screenshot fixture, before (a frame grabbed from the video) and after (the site's picture; the fixture stands in for the site with its generic scene at 1920 px, so the difference is visible offline):
Test plan
CGO_ENABLED=0 go test ./packages/core/... ./packages/media/... ./apps/kando/...passesgo tool mygo vet .inapps/kandois cleanTestEmbeddedCover(real ffmpeg): cover art comes back byte for byte, and a video without cover art has noneTestPosterIsTheSitesCover: a grabbedcover.jpgis replaced by the site's PNG, saved as JPEG; the picture is fetched once and kept in the cache; finding it again does not rewritecover.jpgTestPosterKeepsItsCoverWhenTheSiteHasNone: a failed fetch leavescover.jpguntouchedTestPosterOfALocalVideoIsItsCoverArtTestCoverJPEG: WebP becomes JPEG, JPEG stays as is, and an HTML error page is rejectedKANDO_SCREENSHOTS=… go test -run TestScreenshotsLibraryrenders the newlibrary-site-coverscene