Fix laggy high resolution videos in Chromium #6153
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6093
Regression from #5932
Chromium does not allow to increase the resolution of a video stream once the video stream is cloned. If a video stream is requested without any constraint, the video stream is returned with a resolution around 640x480. Therefore, when Chromium is used the streams needs to be explicitly requested with a high resolution to be able to increase the resolution later as needed.
As the requested resolution is a loose constraint the resolution was requested as 1920x1200 instead of the more common 1920x1080 to try to cover most cases. However, if a camera does not exactly provide 1920x1200 but 1920x1080 and also an even higher resolution Chromium may choose to crop and scale that higher resolution video rather than using the 1920x1080 video.
The problem is that Chromium may choose to do that even if the higher resolution video has an incredibly low frame rate (for example, Chromium is able to get 2304x1296 and 2304x1536 videos from the Logitech C920, but only at 2 FPS). Moreover, it seems that once the stream is cloned Chromium is not able to then get a lower resolution but higher frame rate video; it seems to be stuck with the original stream and just scale it as needed, so the lower frame rate is still kept.
To fix this now the initial stream is requested with both a high resolution and a high frame rate. This way Chromium needs to balance both constraints and thus provide a video without the hightest resolution but with an acceptable frame rate.