Tag: Ant Media Server

  • Steaming to Anti Media Server using ffmpeg

    To team a video io Anti Media Server using ffmpeg command line, use

    ffmpeg -re -i VIDEO_FILE.mp4 -codec copy -f flv ANT_MEDIA_SERVER_RTMP_URL
    

    Example

    ffmpeg -re -i video.mp4 -codec copy -f flv rtmp://stream.serverok.in/LiveApp/225873992721868053400782
    

    Cammand with more steam option

    ffmpeg -re -i 'video.mp4'  -c:v libx264 -b:v 1600k -preset ultrafast -b 900k -c:a aac -b:a 128k -s 1920x1080 -x264opts keyint=50 -g 25 -pix_fmt yuv420p -f flv rtmp://stream.serverok.in/LiveApp/225873992721868053400782
    

    See Ant Media Server

  • Ant Media Server Ubuntu firewall configuration

    Ant Media Server Ubuntu firewall configuration

    To enable firewal for Ant Media Server on Ubnuntu server, use following rules

    ufw allow ssh
    ufw allow http
    ufw allow https
    ufw allow 1935/tcp
    ufw allow 5080/tcp
    ufw allow 5443/tcp
    ufw allow 5000:65000/udp
    enable ufw
    

    After enabling, you will have following status

    root@server:~# ufw status
    Status: active
    
    To                         Action      From
    --                         ------      ----
    22/tcp                     ALLOW       Anywhere                  
    80/tcp                     ALLOW       Anywhere                  
    443/tcp                    ALLOW       Anywhere                  
    1935/tcp                   ALLOW       Anywhere                  
    5080/tcp                   ALLOW       Anywhere                  
    5443/tcp                   ALLOW       Anywhere                  
    5000:65000/udp             ALLOW       Anywhere                  
    22/tcp (v6)                ALLOW       Anywhere (v6)             
    80/tcp (v6)                ALLOW       Anywhere (v6)             
    443/tcp (v6)               ALLOW       Anywhere (v6)             
    1935/tcp (v6)              ALLOW       Anywhere (v6)             
    5080/tcp (v6)              ALLOW       Anywhere (v6)             
    5443/tcp (v6)              ALLOW       Anywhere (v6)             
    5000:65000/udp (v6)        ALLOW       Anywhere (v6)             
    
    root@server:~# 
    

    Port forwarding

    You can forward port 80 and 443 to Ant Media Server, so you don’t have to use ports.

    You can use following iptables commands

    sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5080
    sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 5443
    

    To make it permanent, edit

    vi /etc/ufw/before.rules
    

    In the beginning of the file, find

    *filter
    

    Add above

    *nat
    :PREROUTING ACCEPT [0:0]
    -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 5080
    -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 5443
    COMMIT
    

    Restart ufw firewall

    ufw disable
    ufw enable
    

    See Ant Media Server

  • Ant Media Server

    Ant Media Server is a media streaming server with WebRTC support.

    https://antmedia.io
    Install Ant Media Server on CentOS 8
    Ant Media Server Ubuntu firewall configuration
    Steaming to Anti Media Server using ffmpeg

    Open Source versiong of Ant Media Server can be downloaded from

    https://github.com/ant-media/Ant-Media-Server

    Install Anti Media Server on Ubuntu 18.04

    At the time of writing this post, latest version of Ant Media Server is ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip, replace it with latest version available on github.

    cd /usr/local/src
    wget https://github.com/ant-media/Ant-Media-Server/releases/download/ams-v2.0.0/ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip
    wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh 
    chmod 755 install_ant-media-server.sh
    ./install_ant-media-server.sh ant-media-server-2.0.0-community-2.0.0-20200504_1842.zip
    

    After installation, you will see Ant Meida Server listens on following ports

    [root@Ant-Media-Server ~]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 127.0.0.1:5599          0.0.0.0:*               LISTEN      1594/jsvc.exec      
    tcp        0      0 0.0.0.0:34501           0.0.0.0:*               LISTEN      1594/jsvc.exec      
    tcp        0      0 0.0.0.0:1935            0.0.0.0:*               LISTEN      1594/jsvc.exec      
    tcp        0      0 0.0.0.0:5080            0.0.0.0:*               LISTEN      1594/jsvc.exec      
    [root@Ant-Media-Server ~]# 
    

    To access Ant Media Server, go to

    http://your-server-ip:5080

    When visiting first time, you will be asked to create a new user.

    Ant Media Server

    Installing SSL

    To install SSL, you need to point a domain or sub domain to server IP, then run following commands

    cd /usr/local/antmedia
    ./enable_ssl.sh -d YOUR_DOMAIN_HERE
    

    After installation, you will be able to access site using HTTPS on following URL

    https://YOUR_DOMAIN_HERE:5443

    Test Video Streaming Applictaion available at

    https://YOUR_DOMAIN_HERE::5443/WebRTCApp/

    Manage Anti Media Server

    To start/stop/restart Ant Media Server, use

    systemctl start antmedia
    systemctl stop antmedia
    systemctl restart antmedia
    

    Firewall

    Anti Media Server use following ports

    tcp:1935 - RTMP
    tcp:5080 - HTTP
    tcp:5443 - HTTPS
    tcp:5554 - RTSP
    udp:5000-65000 - WebRTC & RTSP