Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rotated videos #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/thumbnailer_shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ function Thumbnailer:get_thumbnail_size()
if not (video_width and video_height) then
return nil
end
local rotate = mp.get_property_number("video-params/rotate")
if rotate ~= nil and rotate % 180 == 90 then
Comment on lines +239 to +240
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local rotate = mp.get_property_number("video-params/rotate")
if rotate ~= nil and rotate % 180 == 90 then
local rotate = mp.get_property_number("video-params/rotate", 0)
if rotate % 180 == 90 then

It's cleaner to have a default and avoid checking for nil.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed what happens with my test file if the thumbnails are generated before the video is rotated

Some insight from thumbfast, if we're missing rotate info on the first run, we queue another check in 0.05s (in effect the next even loop).
This is obviously hacky, it's a leftover of when thumbfast queried properties when needed instead of watching for changes and caching the value.
I need to rewrite this to call info() within watch_changes() when video-params/rotate changes, that way it's no longer racy. Though this logic may not be needed at all anymore as we delay announcing until video-out-params is available.

We should do a similar thing in mpv_thumbnail_script, return nil in get_thumbnail_size() until video-params/rotate is available (is it guaranteed to eventually exist?). There is already a check for video-dec-params/dw, video-dec-params/dh. The issue may go away if we make the check more robust.

video_width, video_height = video_height, video_width
end

local w, h
if video_width > video_height then
Expand Down