user234683 / youtube-local

browser-based client for watching Youtube anonymously and with greater page performance
GNU Affero General Public License v3.0
540 stars 65 forks source link

When in theater mode, video height exceeds screen viewport #171

Closed Yogotami closed 10 months ago

Yogotami commented 1 year ago

As title says and using Firefox (latest release), video is bigger than my screen size. image

Changing the value of height in #video-container-inner from height: 100% to height: calc(100vh - 50px) seems to resolve the problem. image

image

This 50px comes from trial and error but does not resolve the entire problem as it creates another: image

As I'm not as savvy as a lot of you guys, I have no idea how to decisively fix this.

molytov commented 1 year ago

I found a sort of band-aid solution. In youtube-local/youtube/templates/watch.html, go to Line 90. Change the % from 100% to a smaller value. I found 60% works for 1080p videos, but this differs depending on resolution.

padding-top: calc(100%*var(--video_height)/var(--video_width)); Change to padding-top: calc(60%*var(--video_height)/var(--video_width));

Restart the service to ensure changes take effect.

This actually kind of exposes another issue, which is the fact that the video player size changes with the resolution setting. This solution only works as long as you don't change resolutions. If you lower resolution to something like 360p, then your player will be much smaller. The yt-local fork on SourceHut seems to not have this issue, so it might help to see how it handles the player dimensions.

user234683 commented 1 year ago

This actually kind of exposes another issue, which is the fact that the video player size changes with the resolution setting.

This is intentional. If the video player size is too large for the height of the video, then the video will be blurry (e.g. you wouldn't want to go fullscreen on a 240p video). Whereas if it is too small, then most of the resolution of the video is being ignored (you would want to watch a 1080p/4k video on fullscreen)

So the displayed height of the video in pixels needs to be equal to height of the video's resolution (360 pixels high for 360p). But if the video resolution is too big, the width needs to not exceed the browser width. So you need to scale the video down, while keeping the aspect ratio, which CSS is really bad at unless you have the required width available in pixels (because it won't accept percentages in the calculations).

To make things really fun, CSS does not provide the width of the browser window. It provides the width of the window plus the width scrollbar in the form of 100vw, which is pretty useless for this purpose (or any purpose really) since we can't exceed the scrollbar and do not know what width it is.

If that was it, maybe this would be tractable, but there's other things as well:

Unfortunately, CSS is not well designed for trying to accomplish this, or really anything at all. I've had a tower of ducttape and ugly hacks that makes this work, but the browser vendors keep changing/breaking stuff :\

giphy-4031660982

Does it happen on latest chromium too?