Conversation
last atlas index still has incorrectly sized thumbnails
has wrong stride? wrong estimated number of thumbnails?
|
On Windows beside reverting 9deb073 i also had to remove Using Also about Twitch vods, i wonder if this won't be a potential issue here. |
|
Can reproduce, turns out in newer mpv versions (0.39+?) vo=null no longer works with the encoding mode? I removed it.
This is also a newly introduced issue, and it's completely irrelevant to us. They'll fix it eventually, probably. Love running into new issues after updating mpv, wonder what else it broke (: |
| {input = path_ytdl, patterns = youtube_patterns_free, condition = function(input) return true end}, | ||
| {input = path, patterns = youtube_patterns, condition = function(input) return path_has_prefix end}, | ||
| {input = path, patterns = twitch_patterns, condition = function(input) return path_has_prefix and string.match(input, twitch_base) end}, | ||
| {input = referer_ytdl, patterns = youtube_patterns_free, condition = function(input) return input ~= "" end}, |
There was a problem hiding this comment.
These *_ytdl variables just seem to be longer versions of the stripped ones, so why check against them?
| {input = path_ytdl, patterns = youtube_patterns_free, condition = function(input) return true end}, | |
| {input = path, patterns = youtube_patterns, condition = function(input) return path_has_prefix end}, | |
| {input = path, patterns = twitch_patterns, condition = function(input) return path_has_prefix and string.match(input, twitch_base) end}, | |
| {input = referer_ytdl, patterns = youtube_patterns_free, condition = function(input) return input ~= "" end}, | |
| {input = path, patterns = youtube_patterns_free, condition = function(input) return true end}, | |
| {input = path, patterns = youtube_patterns, condition = function(input) return path_has_prefix end}, | |
| {input = path, patterns = twitch_patterns, condition = function(input) return path_has_prefix and string.match(input, twitch_base) end}, | |
| {input = referer, patterns = youtube_patterns_free, condition = function(input) return input ~= "" end}, |
There was a problem hiding this comment.
The freeform patterns in youtube_patterns_free match strings with anything at the start. Because the user may have prefixed the path with ytdl:// to force ytdl on their end, which is an mpv invention that the yt-dlp command line doesn't understand, we have to make sure we're matching on the version on the path that we've stripped the ytdl:// prefix from.
For clarification, the ytdl_prefix pattern replace (^ytdl://(.+) -> %1) is used to get the path without this prefix while falling back to the full string if it didn't match.
Edit: Actually thinking about it some more I'm not sure I understand my own code anymore, why do I need to perform these matches on the version of the path that wasn't stripped from the http prefix? I'll look into it.
| -- Storyboard upscaling factor | ||
| local scale = properties["display-hidpi-scale"] or 1 | ||
| if sb.width / sb.height > options.max_width / options.max_height then | ||
| real_w = options.max_width * scale | ||
| real_h = math.floor(sb.height / sb.width * real_w) | ||
| real_w = math.floor(real_w) | ||
| else | ||
| real_h = options.max_height * scale | ||
| real_w = math.floor(sb.width / sb.height * real_h) | ||
| real_h = math.floor(real_h) | ||
| end | ||
| local storyboard_scale = {w=real_w/sb.width, h=real_h/sb.height} | ||
| local thumbnail_size = {w=real_w, h=real_h} | ||
| effective_w, effective_h = real_w, real_h | ||
| info(real_w, real_h) |
There was a problem hiding this comment.
Scaling the storyboards to not fit the max should probably be an option, since it may not look good at some scaling ratios.
thumbfast.lua
Outdated
| for line = 0, thumbnail_size.h - 1 do | ||
| atlas:seek("set", 4 * x_start + (y_start + line) * stride) | ||
| local data = atlas:read(thumbnail_size.w * 4) | ||
| if data ~= nil then | ||
| thumb_file:write(data) | ||
| end | ||
| end |
There was a problem hiding this comment.
That seems like an awful lot of writes. Can't you just read the lines one by one, and keep appending them to a buffer, then write the complete buffer all at once?
There was a problem hiding this comment.
io.open very likely defaults to buffered io. Like most standard libraries in most languages.
| "^"..anycase("player%.twitch%.tv/.*[?&]video=v?")..twitch_id, | ||
| } | ||
|
|
||
| local function storyboard_supported_url(path, referer) |
There was a problem hiding this comment.
I also wonder if there even is any point having checks here as to whether the site supports yt-dlp, instead of just always attempting to fetch storyboards, and only continuing if they are returned.
There was a problem hiding this comment.
This would slow down the initial load of any non-storyboard network thumbnails, and cause extra requests because yt-dlp still has to fetch the list of all formats. It's not smart enough to lazily fetch format info based on --format and what's supported, which was a surprise to me. (and somewhat a blessing because it means that the existing json returned by ytdl_hook in newer mpv versions will always contain storyboard info, removing the need to spawn yt-dlp for those mpv versions)
I agree that this code is overengineered, but it's a port of the patterns from yt-dlp itself and should cover all cases.
messy, and doesn't auto-update in all cases yet crop handling is still missing it's progress (:
Supports YouTube videos and Twitch VODs. cf. #3, #111
No actual logic is specific to those sites, it's just that yt-dlp doesn't currently support anything else.
I may make PRs to yt-dlp later implementing "storyboards" for more websites.
It's good enough that I'd like others to try it and report issues.
Commits are a mess because I'm still experimenting a lot, they'll be squashed eventually.
I wonder if it may be possible to avoid spinning up a whole mpv process for each atlas, and instead use EDL or lavf:// to open multiple images and save them separately with an output template.
TODO:
thumbfast-renderAPI (even though there are currently no users of it)My primary test videos: