Giter VIP home page Giter VIP logo

Comments (2)

molytov avatar molytov commented on June 3, 2024

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.

from youtube-local.

user234683 avatar user234683 commented on June 3, 2024

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:

  • For long (e.g. 3 hour) videos, if the resolution is say 360p, it will be difficult to scrub in the video, because 1 pixel might correspond to 3 minutes. So you have to sit there and wait 3 minutes to get to the desired part, after painstakingly trying to move your mouse a single pixel. The solution to this is to widen the scrub-bar to be the entire width of the screen if necessary.
  • Both plyr and non-plyr (browser default) need to be supported. Plyr puts the <video> inside a bunch of <div>s, whereas the browser default does not. So both cases need to be handled.

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?

from youtube-local.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.