With the first version of Ant Media Server, developers can make users broadcast live video from their browser with WebRTC, and Live Stream can be distributed to many with RTMP and HLS, thanks to WebRTC Adapter. In other words, users can broadcast live video from browsers as they do with a flash plugin, fortunately, this time there is no need for any third-party plugin.
By the way, Ant Media Server is a free and open source media server that has some additional life-saving features for developers. For instance, it supports MP4 recording for live RTMP streams. It supports HLS and RTSP so that streams live or VoD can play almost on all web browsers. It has also 360-degree video and adaptive bitrate support in the enterprise edition.
Table of Contents
- Broadcast Live Video with WebRTC to Ant Media Server
- Watch Live Stream with RTMP and HLS
- Play Recorded VoD Stream with RTMP and HTTP
- Reverse WebRTC Adapter
Broadcast Live Video with WebRTC to Ant Media Server
Let’s return back and let me explain how to try this feature step by step
- Firstly, download Ant Media Server at https://antmedia.io and extract to any folder you prefer.
- Secondly, for mac and linux users execute the start.sh file. For windows users, add the full path of ant-media-server/lib/native to the PATH environment variable of the system and then execute start.bat
- Thirdly, Server should be running right now. Go to http://localhost:5080/WebRTCApp and let web app access the camera and microphone. Then you may need to refresh the page
- Fourthly, you should see yourself in the browser and just press the “Start Broadcasting” button.
Right now, you are broadcasting to media server and it is time to watch the live stream
Watch Live Stream with RTMP and HLS
You can watch RTMP stream with ffplay, vlc, etc with the command below.
ffplay “rtmp://localhost/WebRTCApp/stream1 live=1"
If you want to watch HLS stream, you need to do two things. First, remove * at line below in ant-media-server/webapps/WebRTCApp/web.xml file
<security-constraint> <web-resource-collection> <web-resource-name>Forbidden</web-resource-name> <url-pattern>/streams/*</url-pattern> <! — remove “*” at this line — > </web-resource-collection> <auth-constraint/> </security-constraint>
Secondly, restart the server and broadcast again, you can now play HLS with the command below
Moreover, after you stop broadcasting, you can play the recorded MP4 file both on RTMP and HTTP.
Play Recorded VoD Stream with RTMP and HTTP
To play with RTMP, type the below command
To play with HTTP type the below command
Reverse WebRTC Adapter
Lastly, there is also a reverse adapter for WebRTC, it means you can watch any stream in the server with WebRTC, you can access the reverse adapter at http://localhost:5080/WebRTCApp/player.html
Meanwhile, RTMP to WebRTC adapter is not very efficient, it uses more resources than it should be so there will be efficieny improvement in coming releases.
Lastly, if you have any question, please drop a comment or send an email to contact at antmedia dot io
You can try Ant Media Server for free with all features!
You can download native Android and iOS WebRTC SDKs and integrate them into your applications for free!
Ant Media Server Github Wiki