GST-ANT Fusion

Plugin that integrates Gstreamer with Ant Media Server

About the Gstreamer plugin​ for Ant Media Server

The GST-ANT Fusion plugin seamlessly integrates Ant Media Server with Gstreamer that is a well-know open-source multimedia framework.

Who can use this plugin?

The plugin is a game-changer for streamers and businesses providing the ability to customise streaming pipelines to suit specific use cases and preferences. Whether it’s RTSP, RTP, RTMP, or even a combination of these protocols, the plugin empowers users to define and create their own Gstreamer  pipelines that precisely align with their streaming requirements.

Getting started

Prerequisites:

You need to have an active Ant Media Server license. You can subscribe through AWS Marketplace and deploy Ant Media Server with just one click. Or you can directly subscribe to a self-hosted license on our website. Check out our documentation to learn how to deploy Ant Media Server. 

Installing:

  • Go to GST-ANT-FUSION
  • Download the dist.zip file according to your Ant Media Version
  • Unzip the file dist.zip file
  • Run sudo sh gst_plugin_install.sh
  • restart the server
  • sudo service antmedia restart

The plugin comes with RTSP , RTMP and RTP output capabilities by default also you can register any Gstreamer pipeline you want by simply calling some rest endpoints. 

RTSP output

There are two ways to register a stream for RTMP output.

  1. If you want to have RTSP output for any stream, you can simply send a REST API request to enable RTSP for that particular stream.
  2. If you want to have RTSP output for every stream without having to call a REST API, you can simply set RTSP by default in the plugin configuration file. In this way, you don’t need to call the rest API, and the RTSP stream will be available for every stream that you publish to Ant Media Server.

    REST API Method:

    1. You can send a video stream either with WebRTC, RTMP, RTSP, or SRT.
    2. send a REST API request. RTSP supports both UDP and TCP, so you can set the protocol as TCP or UDP
    curl -X POST -H "Content-Type: application/json" -d '{"streamId":"stream1","pipeline_type":"RTSP_OUT","protocol":"TCP"}' http://localhost:5080/LiveApp/rest/pipeline/register-pipeline/
    1. Play the stream with ffplay..
    2. Change the IP Address in the command.
    3. ffplay rtsp://127.0.0.1:8554/stream1

    Enabling RTSP by Default In the Configuration File:

    1. Edit to /usr/local/antmedia/gst-plugin.cfg
    2. Set RTSP in Default Protocols to 1 to set the desired protocol and port for RTSP output.
    3. # set true or 1 for enabling by default 
      [DefaultProtocols]RTSP=1
      RTMP=0
      [RTSP]Port=8554
      Protocol=TCP
      [RTMP]appname=rtmpout
      Port=1935
      [RTP]
    4. Restart the server.

    5. Now for every stream that is published to the Ant Media server, The RTSP output stream will be available by default.

    RTMP Output Configuration

    1.Create a new Appname on Ant Media with the name of rtmpout.

    2. Set the following in application settings of rtmpout application :

      
    settings.webRTCEnabled=false
    settings.hlsMuxingEnabled=false
    dashHttpStreaming=false
    rtmpPlaybackEnabled=true
      
    

    REST API Method:

    To enable RTMP output for a specific stream using the REST API, you can send a request as follows:

      
    curl -X POST -H "Content-Type: application/json" -d '{"streamId":"stream1","pipeline_type":"rtmp_OUT","protocol":"TCP"}' http://localhost:5080/LiveApp/rest/pipeline/register-pipeline/
      
    

    To play the stream using ffplay, use the following command:

      
    ffplay rtmp://localhost/rtmpout/streamid_rtmp_out
      
    

    Make sure to change the IP address in the command accordingly.

    Enabling RTMP by Default in the Configuration File:

    1. Edit the configuration file:
    2.     
      sudo nano /usr/local/antmedia/gst-plugin.cfg
          
        
    3. Set RTMP in Default Protocols to 1 to enable RTMP by default:
    4.     
      [DefaultProtocols]
      RTMP=1
      RTSP=0
          
        
    5. Restart the Ant Media server:
    6.     
      sudo systemctl restart antmedia
          
        

    Now, RTMP output will be enabled by default for every stream published to the Ant Media server. Adjust the configuration settings as needed.

    To play the stream using ffplay, use the following command:

      
    ffplay rtmp://localhost/rtmpout/streamid_rtmp_out
      

    RTP OUTPUT (Supports only Video for now)

    1. You can send a video stream either with WebRTC , RTMP , RTSP or SRT.
    2. send a REST API request.
    curl -X POST -H “Content-Type: application/json” -d ‘{“streamId”:”stream1″,”pipeline_type”:”RTP_OUT” , "port": "5000" , "host","127.0.0.1"}’ http://localhost:5080/LiveApp/rest/pipeline/register-pipeline/
    Change the IP Address in the command.
    gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! autovideosink

    Custom Gstreamer Pipeline

    1. You can send a video stream either with WebRTC , RTMP , RTSP or SRT.
    2. send a REST API request and pass your own custom gstreamer pipeline with it.
    Encoded video element will be available with the name element name as video and encoded audio element will be available with the name as audio. You can access the elements by name and to further complete the pipeline as desired. For example, you can get the video and audio and link it some thing like this.
    mp4mux name=muxer  video. !  muxer.  ! audio. !   muxer. ! filesink  location=./abc.mp4
     
    If you don’t need to use any one of them you can simply link it to fakesink. For example, if you don’t need audio then you can connect audio. ! fakesink 
     
    1. Recording with gstreamer plugin using a custom Muxer  (MKV, FLV, etc). The file will be saved in /usr/local/antmedia  driectory 
     
    curl -X POST -H "Content-Type: application/json" -d {"streamId":"streamId_6FGwsZSNW","pipeline_type":"Gstreamer","protocol":"TCP", "pipeline":"matroskamux name=muxer  video. !  muxer.  ! audio. !   muxer.   ! filesink  location./abc.mp4 "}  http://localhost:5080/LiveApp/rest/pipeline/register-pipeline/ 

    2. Re-Stream to an SRT-Server 

    curl -X POST -H "Content-Type: application/json" -d {"streamId":"streamId_6FGwsZSNW","pipeline_type":"Gstreamer","protocol":"TCP", "pipeline":"mpegtsmux name=muxer  video. !  muxer.  ! audio. !   muxer.    ! srtsink uri=srt://SRT_SERVER_ADDRESS:PORT?streamid=streamid "} http://localhost:5080/LiveApp/rest/pipeline/register-pipeline/

    3. Save only Audio of the stream as mp3 file.

    curl -X POST -H "Content-Type: application/json" -d {"streamId":"streamId_6FGwsZSNW","pipeline_type":"Gstreamer","protocol":"TCP", "pipeline":"lamemp3enc name=muxer video. ! fakesink. ! audio. ! muxer. ! filesink location=abc.mp3 "} http://localhost:5080/LiveApp/rest/pipeline/register-pipeline

    Support

    This plugin was developed by Ant Media Team. Create a new issue or search for related keywords to find an answer right away on our Github discussions.

    Screenshots

    RTSP , RTMP , RTP, SRT and many more Playback options.

    chatsimple