Automatic aspect ratio detection - tamius-han/ultrawidify GitHub Wiki

By default, automatic detection will run on every site this extension is enabled for. It does what it says on the tin: it attempts to detect aspect ratio of the video by periodically looking at a video frame. If you do not like this feature, you can disable it globally, for a given site or even for a specific video. Changing aspect ratio manually (either via keyboard or via popup) will also pause automatic aspect ratio detection for the current video.

The default interval between aspect ratio checks is 666 milliseconds. Ideally, aspect ratio checks would happen more often, as some videos may change aspect ratios multiple time throughout. Once every frame would be ideal, but in practice it turns out that this would consume too much RAM (because javascript garbage collections seems to be garbage). Due to technical limitations, though, we have to use a compromise.

Autodetection is much tougher issue than it seems at a first glance. Most of the time it's easy, but sometimes it can be hard. Because of this, autodetection is sometimes too eager, and not eager enough at other times — but most of the time, it seems to do the job just fine.

DRM-protected sites

Some sites use DRM. DRM measures are designed specifically to prevent scripts from looking at video frames. Since that's exactly what this extension uses to determine aspect ratio of a video, autodetection is not possible on sites that use DRM (Netflix and the likes). Firefox is slight exception to this.

Firefox offers an API that can be used to take screenshots of the page. Turns out that you can use this API to work around the above limitation. Usage of this API has its own limitations. Due to those limitations, automatic detection on DRM-protected sites in Firefox keeps a thin black bar at the top and the bottom of the video.