Home > Software engineering >  WebRTC: video blinks when upgrading
WebRTC: video blinks when upgrading

Time:04-02

description

WebRTC sample https://webrtc.github.io/samples/src/content/peerconnection/upgrade/ is about adding video track to an existing peer connection which contains an audio track. I revise it a little bit, and make a reverse. I change the program from adding video track to audio track to adding audio track to video track. Then I find that the remoteVideo tag blinks when this line is being executed.

remoteVideo.srcObject = e.streams[0];

In other words, it will blink when we add an audio track to a html5 video tag which is playing a video track.

expectation

No blink.

question

Is it possible to add audio track perfectly (no blink)? If yes, how?

CodePudding user response:

This is a well-known issue with current in-browser implementations of WebRTC.

A known workaround is to create a new HTMLVideoElement that displays the new stream, and then substitute the old element with the new one in the DOM. Don't forget to set the old element's srcObject to null so it can be garbage collected.

  • Related