Fix video zoom jump with background blur when changing resolution
The input track is played in a video element which, in turn, is drawn on
the canvas used to calculate the segmentation mask and on the output
canvas. When the resolution of its input track changes a video element
may still play the track using the old resolution for some frames (it
happens with real hardware cameras, although apparently not with virtual
devices), even if "track.getSettings()" already returns the new
resolution.
Due to this mismatch, when the resolution of the input track changed
(for example, due to a quality change in a call with several
participants), the video could zoom in and out, as the output canvas
size was based on the new size, while the video element drawn on it was
still using the old size.
Fortunately, the "videoWidth" and "videoHeight" attributes of the video
element seem to reflect the actual size of the video being played, so
those values can be used to do the calculations instead of relying on
the expected video size.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Loading
Please register or sign in to comment