Streaming live video
While streaming audio is great, live video is even more gratifying. Using the WebRTC protocol, we can stream video in addition to audio and simply pipe it into an HTML video element instead of an audio element.
In this recipe, we will create a peer-to-peer connection where we can allow two users to chat using live video.
How to do it…
To stream live video with Socket.IO, follow these steps:
- First, we need to create a
server.js
file. This file will be responsible for managing sockets as they join or leave. It will also be responsible for allowing the sockets to connect to one another to initiate a WebRTC session:var express = require('express'), app = express(), http = require('http'), socketIO = require('socket.io'), fs = require('fs'), ...
Get Socket.IO Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.