MENU
WebRTC- Broadcasting with Red5
Red5 is an open-source media server that allows you to broadcast live video to many viewers simultaneously.
Note that to use Red5, you should first install Java. At the time of writing, the package that works is JRE_1.8.0_261_64-bit. (You can also install its superset, the JDK). Remember to point the JAVA_HOME environment variable to the root directory of the JRE package. You will need to open up and forward several ports at your router such as 5080, 1935, 8554, and 6262 too.
While webpages are served over the protocol HTTP(S), and Web Sockets connect over WS(S), live videos are broadcast over RTMP(S).
<!doctype html><html>
<head><script src="https://webrtchacks.github.io/adapter/adapter-latest.js"></script>
</head>
<body>
<video id="red5pro-publisher" autoplay muted></video>
<script src="red5pro-sdk.min.js"></script>
<script>
(function (red5prosdk) {
var publisher = new red5prosdk.RTCPublisher();
publisher.init({
protocol: 'ws', // wss
port: 5080, // 443
host: 'localhost', // myremotesite.com
app: 'live',
streamName: 'mystream',
rtcConfiguration: {
iceServers:[{urls: 'stun:stun2.l.google.com:19302'}],
iceCandidatePoolSize: 2,
bundlePolicy: 'max-bundle'
},
streamMode: 'live',
mediaElementId: 'red5pro-publisher',
bandwidth: {
audio: 56,
video: 512
},
mediaConstraints: {
audio: true,
video: { width: { exact: 640 },
height: { exact: 480 },
frameRate: {min: 8, max: 24 }}}
}).then(function() {
return publisher.publish();
}).catch(console.error)
})(window.red5prosdk);
</script></body></html>
<!doctype html><html><head>
<script src="https://webrtchacks.github.io/adapter/adapter-latest.js"></script>
<link href="red5pro-media.css" rel="stylesheet">
<script src="screenfull.min.js"></script></head><body>
<video id="red5pro-subscriber"
class="red5pro-media red5pro-media-background"
autoplay controls>
</video>
<script src="red5pro-sdk.min.js"></script>
<script>
(function (red5prosdk) {
var subscriber = new red5prosdk.RTCSubscriber();
subscriber.init({
protocol: 'ws',
port: 5080,
host: 'my-site.com',
app: 'live',
streamName: 'mystream',
rtcConfiguration: {
iceServers:[{urls: 'stun:stun2.l.google.com:19302'}],
iceCandidatePoolSize: 2,
bundlePolicy: 'max-bundle'},
mediaElementId: 'red5pro-subscriber',
subscriptionId: 'mystream' +
Math.floor(Math.random() * 0x10000).
toString(16),
videoEncoding: 'NONE',
audioEncoding: 'NONE'
}).then(function(subscriber) {
return subscriber.subscribe();
}).then(function(subscriber) {
}).catch(console.error);
})(window.red5prosdk);
</script>
</body></html>
Alternative media servers include the