Try Live Demo
Important note: Adobe stopped supporting Flash in 2020. This ended the use of RTMP on Last-mile delivery (RTMP play). It is still in use in the first-mile delivery(RTMP ingest), but HTML5-based protocols have already begun replacing it in the first-mile delivery and these protocols are more supported. Let’s look at what you need to consider when looking for an alternative to RTMP. You can find more information here.

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://mirror.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

Ultra low latency streaming ant media

  • Fourthly, you should see yourself in the browser and just press the “Start Broadcasting” button.

Webrtc Live streaming ant media

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

ffplay http://localhost:5080/WebRTCApp/streams/stream1.m3u8

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

ffplay rtmp://localhost/WebRTCApp/stream1.mp4

To play with HTTP type the below command

ffplay http://localhost:5080/WebRTCApp/streams/stream1.mp4

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

Type Stream Name and Press the Start Broadcasting Button

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

Useful Links

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

You would want to check Ultra Low Latency Video Streaming and 7 Use Cases and Future of Ultra-Low Latency Streaming Market.

Categories: Tutorial

Ahmet Oguz Mermerkaya

Oguz is the co-founder of Ant Media. His tech stack includes VxWorks, UML, Rhapsody in C++. Java, OSGi, Swing, JSF, Web, PHP, FFmpeg API, Native WebRTC, Java EE, Hibernate, Spring, MongoDB, MySQL, Angular, JavaScript, HTML5, Android (Native) and iOS (Native). Oguz is one of the writers of "Merhaba Android", one of the first books published in Turkey about Android app programming. His second book is about HTML5 & CSS3. He has attended several conferences and universities talking about Android, business life and technical issues. He is a member of the GDG Community and also the founder of GDG Ankara.

chatsimple
Warning: Undefined array key "promocode" in /home/mirror.antmedia.io/public_html/wp-content/themes/hestia-child/footer.php on line 70