Peertube: Cap the maximum resolution to the screen resolution

Created on 28 Jun 2018  路  13Comments  路  Source: Chocobozzz/PeerTube

note: adapted from https://framacolibri.org/t/choix-automatique-de-la-resolution-video/3204

Right now the resolution is selected automatically in order to fit the maximum bandwidth the connection allows. However it doesn't make sense to watch a 1080p video on a 720p screen, for instance.

Adding a check detecting the current window size and adapting the resolution if necessary would fit the use and allow to avoid consuming more bandwidth than necessary.

Type good first issue

All 13 comments

Do we check the window size or the video element size?

As a side note, does PeerTube use adaptive bitrate streaming or is it a one time bandwidth check before playback begins?

@rezonant it is adaptative.

It was introduced in beta.4 with https://github.com/Chocobozzz/PeerTube/commit/a8462c8e3a61f4f7314fe18c0c10cc2946c254d1.

@Chocobozzz we should check for the video element size.

Can I take this issue ?

Implementation should continually affect the adaptive bitrate selection as well, to handle upgrading resolution when going full screen, resizes etc

@ns23 sure!

Can you suggest me any start point, from where I start working on this issue.

In this function: https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/player/peertube-videojs-plugin.ts#L361

We choose the appropriate resolution. You could just reject resolution (in fact this is the video width) that are > to the width of the video element.

Okay, I will go through the code, and start working on the issue

Hello, Before creating a PR I want to know whether I am following correct approach or not .
In this function: https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/player/peertube-videojs-plugin.ts#L380
If I add following filter function, will it solve this issue ?

// Cap the maximum resolution to the screen resolution
    filteredFiles = filteredFiles.filter(f => f.resolution.id <= this.playerElement.width)

Yep, but put it before the current filter function:

const filteredFiles = this.videoFiles
  .filter(... your filter)
  .filter(... current filter)

Okay, I will make the changes and create a PR

Was this page helpful?
0 / 5 - 0 ratings

Related issues

milleniumbug picture milleniumbug  路  3Comments

Angedestenebres picture Angedestenebres  路  3Comments

filmaidykai picture filmaidykai  路  3Comments

zilti picture zilti  路  3Comments

XenonFiber picture XenonFiber  路  3Comments