Ant Media Server Documentation

repository·master·Indexed 26 days ago

https://github.com/ant-media/ant-media-server

A scalable, high-performance media server engine for ultra-low latency live streaming via WebRTC, SRT, RTMP, HLS, and other protocols. Supports H.264 and H.265/HEVC codecs, adaptive bitrate streaming, and cloud auto-scaling. Available in Community and Enterprise editions with SDKs for iOS, Android, React Native, Flutter, Unity, and JavaScript. Includes documentation on deployment via Linux, AWS, Azure, and GCP, as well as server management via start.sh and REST API.

Tokens
2.1K
Snippets
0
Records
17
Agent score
89%

What's inside Ant Media Server

  1. Overview of Ant Media Server

    master

    Ant Media Server is a scalable media server designed for ultra-low latency live streaming. It is primarily used for real-time communication (RTC) and adaptive bitrate (ABR) workflows.

    Key Capabilities:

    • Ultra-Low Latency: Supports WebRTC with latency as low as ~0.5s.
    • Protocol Support: WebRTC, SRT, RTMP, HLS, CMAF, LL-HLS, RTSP, and Zixi.
    • Video Codecs: Supports H.264 and H.265/HEVC.
    • Features: Recording, cloud auto-scaling, and adaptive bitrate streaming.
    • SDK Availability: SDKs are available for iOS, Android, React Native, Flutter, Unity, and JavaScript.
  2. Choose between Community and Enterprise Editions

    master

    Ant Media Server is offered in two editions:

    • Community Edition: Provides essential streaming features and is available for free via GitHub releases or cloud marketplaces.
    • Enterprise Edition: Includes advanced features, scalability, and official email support. A 14-day free trial is available for testing enterprise features.
  3. Install and Deploy Ant Media Server

    master

    Ant Media Server can be deployed on-premises or via various cloud marketplaces.

    On-Premises

    • Use the Linux Install Script for direct installation on Linux servers.
    • Configure SSL/TLS for secure streaming.

    Cloud Marketplaces

    Deploy using 1-click applications or marketplace images:

    • AWS: Available in both Community and Enterprise Editions.
    • Azure: Available in both Community and Enterprise Editions.
    • GCP: Available in Enterprise Edition.

    Scaling

    For high-availability and large-scale deployments, you can implement auto-scaling using AWS CloudFormation.

  4. Set Resource Limits (CPU and Memory)

    master

    You can prevent the server from over-consuming host resources by setting limits. When these thresholds are crossed, the server enters a highResourceUsage state, which prevents new publishing or playing sessions to protect stability.

    • Use -c <percentage> to set the CPU limit (e.g., ./start.sh -c 60).
    • Use -e <percentage> to set the Memory limit (e.g., ./start.sh -e 60).
  5. Start Ant Media Server via start.sh

    master

    Use the start.sh shell script to launch the Ant Media Server with various configuration options. The script handles JVM settings, network configurations (IP/Server Name), database connections (MongoDB/Redis), and resource limits.

    Note: If running directly as a non-root user, you may need to manually create and permission the log directory:

    sudo mkdir -p /var/log/antmedia
    sudo chown $USER /var/log/antmedia
  6. Configure TURN/STUN Server settings

    master

    To enable WebRTC relay via TURN/STUN, pass the following flags to start.sh. These settings are applied to the red5-web.properties files of all installed webapps:

    • -a <URL>: Sets settings.webrtc.stunServerURI (e.g., turn:ovh36.antmedia.io).
    • -n <username>: Sets settings.webrtc.turnServerUsername.
    • -w <password>: Sets settings.webrtc.turnServerCredential.
  7. Manage Global Scopes in Server

    master

    The Server class provides mechanisms to register, retrieve, and look up IGlobalScope instances. Global scopes are used to manage shared resources or configurations across the server.

    • registerGlobal(IGlobalScope scope): Registers a new global scope by its name.
    • getGlobal(String name): Retrieves a specific global scope by its name.
    • getGlobalNames(): Returns an iterator over all registered global scope names.
    • getGlobalScopes(): Returns an iterator over all registered IGlobalScope objects.
    • lookupGlobal(String hostName, String contextPath): Performs a hierarchical lookup for a global scope based on the provided hostName and contextPath. It attempts to match the most specific path first and falls back to wildcards (empty host or empty path) if no direct mapping is found.
  8. Map Host and Context Path to Global Scopes

    master

    You can define mappings between a specific host/context path combination and a named IGlobalScope. This allows the server to resolve scopes dynamically during lookups.

    • addMapping(String hostName, String contextPath, String globalName): Creates a mapping for the key hostName/contextPath to the specified globalName. Returns true if the mapping was successfully added, or false if it already existed.
    • removeMapping(String hostName, String contextPath): Removes the mapping associated with the specific host and context path. Returns true if a mapping was removed.
    • removeMapping(String contextPath): Removes any mapping associated with the given contextPath (using an empty host string as the key).
    • getMappingTable(): Returns a Map<String, String> containing all current mappings in the format "scope key / scope name".