What is WebRTC? Video calls in your browser explained
WebRTC is the technology built into every modern browser that lets two people talk by video or voice directly, with no app or plug-in. Here is what happens between clicking Start and seeing someone, in plain English.
Updated
See WebRTC in actionOpens videomegle in Video mode · free · no sign-up
WebRTC in one paragraph
WebRTC stands for Web Real-Time Communication. It is an open standard, published by the W3C, which writes web standards, with the network protocols underneath defined by the IETF. Chrome, Edge, Firefox and Safari all include it, on computers and phones. It gives a web page three abilities: to ask for your camera and microphone, to connect directly to another browser, and to stream audio, video and data over that connection with very little delay. Google Meet, Discord in the browser and many other services use it, and so does videomegle.
What happens when you start a call
Behind the few seconds between clicking Start and seeing someone, the steps look like this:
- Permission. The page asks the browser for your camera and microphone. You see the permission prompt, and nothing is captured until you allow it.
- Signalling. The two browsers need to agree how to talk, but cannot find each other on their own. The website's server passes short messages between them, describing which video and audio formats each supports and how the connection will be encrypted. WebRTC deliberately leaves this step to each website.
- Finding a route. Each browser collects a list of addresses it might be reachable at, called candidates: its address on your home network, its public internet address, and a relay address if one is available. This process is called ICE.
- Testing routes. The browsers try the candidates against each other and pick the best one that works, preferring a direct connection.
- Securing and streaming. The browsers set up encryption keys between themselves, then the audio and video start flowing.
For a random chat, the matching happens just before signalling; we explain that part in how random matching works.
STUN, TURN and why some calls use a relay
Most devices do not have their own public internet address. Your router has one, and it shares it among everything in your home using a technique called NAT. That makes it hard for a browser elsewhere to reach you directly.
- STUN servers solve the common case. Your browser asks a STUN server what your public address looks like from outside, and whether your router places restrictions on incoming connections. With that information, the two browsers can usually connect to each other directly.
- TURN servers handle the rest. Some routers and many corporate, school and mobile networks will not allow a direct connection at all. Then the media is relayed through a TURN server instead. It works, but it adds a little delay and costs the operator bandwidth, so it is used only when nothing else works.
If calls only fail on one particular network, this is usually why; see why video calls fail on some networks.
How WebRTC calls are encrypted
Encryption is not optional in WebRTC. The IETF's WebRTC security architecture states that media must not be sent unencrypted and requires a method called DTLS-SRTP for every audio and video stream. DTLS is the handshake that sets up the keys, between the two browsers, and SRTP is the encrypted format the audio and video travel in. A TURN relay passes these encrypted packets along without being party to that key exchange.
It is worth being clear about what that protects. Encryption stops other people on the network, such as someone on the same café Wi-Fi, from watching your call. It does nothing about the person you are talking to: they see and hear whatever you show them, and could record their screen. That is a reason to be thoughtful about what is on camera, whatever technology the call uses.
What peer-to-peer means for privacy
A direct connection needs each browser to know where to send its packets, so the candidate addresses, including your public IP address, are shared with the other browser during setup. Someone determined could see it. An IP address usually reveals your rough area and internet provider, not your home address, but it is reasonable to want to know about it. We cover this in detail in can someone get your IP address from a video chat and what a WebRTC IP leak is.
Adapting to your connection
WebRTC compresses video with codecs, which are methods for shrinking video to a size the internet can carry. Browsers are required to support VP8 and H.264 for video, and many also support newer, more efficient ones, while audio typically uses Opus, a codec designed for speech and music over the internet. During the call, WebRTC watches for delay and lost packets and adjusts the bitrate continually: it lowers the resolution and frame rate when the connection struggles, and raises them again when it recovers. That is why picture quality varies during a call, and why the data a call uses is not fixed; see how much data a video call uses. Browsers also apply echo cancellation to call audio, which is why calls on laptop speakers are usable at all.
How videomegle uses it
videomegle's server does two jobs: it pairs you with someone in the mode you chose, and it passes the signalling messages so your browsers can find each other. After that, video and voice travel peer-to-peer between the two browsers over WebRTC, encrypted as described above, with a relay server as a fallback when a direct connection is not possible. Calls are not recorded or stored. Messages in the text panel, which is available in every mode, are passed on through our server and are not stored either. Start a video chat and all of the above happens in a couple of seconds.
Sources
Frequently asked questions
Is WebRTC safe?
The technology is designed with security built in: media must be encrypted with DTLS-SRTP, and sites need your permission before using your camera or microphone. The main remaining risk is the person you are talking to, who sees whatever you show them.
Do I need to install anything to use WebRTC?
No. It is built into Chrome, Edge, Firefox and Safari on computers and phones, which is why browser video calls need no app.
What is the difference between STUN and TURN?
A STUN server tells your browser its public address so it can connect directly to the other person. A TURN server relays the call when a direct connection is impossible, at the cost of a little extra delay.
Does WebRTC reveal my IP address?
In a direct connection, the other browser learns your public IP address so it can send you the call. That usually shows your rough area and internet provider, not your home address.