Ingest streams (RTMP/WHIP) or files (HLS, MP4) to LiveKit WebRTC
Ingest streams (RTMP/WHIP) or files (HLS, MP4) to LiveKit WebRTC
WebRTC is proving to be a versatile and scalable transport protocol both for media ingestion and delivery. However, some applications may require integrating with existing workflows or equipment that do not support WebRTC. Universal Ingress provides a way to send media that was generated using such workflows to a LiveKit room.
Universal Ingress is meant to be a versatile service supporting a variety of protocols, both using a push and pull model. Currently, the following protcols are supported:
The Ingress service will automatically transcode the source media to ensure compatibility with WebRTC. It can publish multiple layers with Simulcast. The parameters of the different video layers can be defined at ingress creation time.
To push media to the Ingress, the workflow goes like this:
CreateIngress API (to livekit-server)CreateIngress returns a URL that can be used to push media toThe Ingress service and the LiveKit server communicate over Redis. Redis is also used as storage for the Ingress session state. The Ingress service must also expose a public IP address for the publishing endpoint streamers will connect to. In a typical cluster setup, this IP address would be assigned to a load balancer that would forward incoming connection to an available Ingress service instance. The targeted Ingress instance will then validate the incoming request with the LiveKit server using Redis as RPC transport.
The Ingress service takes a YAML config file:
…The config file can be added to a mounted volume with its location passed in the INGRESS_CONFIG_FILE env var, or its body can be passed in the INGRESS_CONFIG_BODY env var.
Security note on
enable_udp_url_pullOnly enable UDP url pull if you trust both the callers allowed to create ingresses and the network the ingress handlers run on. Unlike
http://andsrt://urls, audp://url doesn't make the handler connect out to the url host: the handler binds a local socket on the address and port taken from the url, and joins the multicast group if one is given. As a result, a caller creating a URL pull ingress can:
- Choose which local port the handler binds, potentially colliding with other services on the host.
- Have the handler ingest unauthenticated traffic. UDP is connectionless, so any host able to reach that port can inject media into the session, or spoof the sender address to disrupt a legitimate feed.
- Have the handler join arbitrary multicast groups and republish whatever it receives into a LiveKit room, using the ingress as a relay for streams on the handler's local network that the caller has no direct access to.
Compatibility note on
psrpc.compressionBus compression requires psrpc v0.7.6 or newer on every node sharing the Redis bus. An older peer ignores the compression marker and tries to decode the gzipped bytes as the message payload, so the message is dropped without an error. Enabling it is therefore a two-stage operator action: roll a build with psrpc v0.7.6+ out to livekit-server, ingress, egress, SIP and any agent workers first, then raise
qualityat the publishers. It is off by default.
max_decompressed_sizeonly affects reading, so it can be set ahead ofquality.
In order for the LiveKit server to be able to create Ingress sessions, an ingress section must also be added to the livekit-server configuration:
ingress:
rtmp_base_url: RTMP url prefix pointing to the Ingress external IP address or load balancer
whip_base_url: WHIP url prefix pointing to the Ingress external IP address or load balancerFor instance:
ingress:
rtmp_base_url: rtmp://my.domain.com/x
whip_base_url: http://my.domain.com/wA stream key will be appended to this prefix to generate the ingress session specific RTMP or WHIP publishing endpoint.
The first step in order to use the Ingress service is to create an ingress session and associate it with a room. This can be done with any of the server SDKs or with the livekit-cli. The syntax with the livekit-cli is as follow:
livekit-cli create-ingress \
--request The request creation JSON file uses the following syntax:
{
"input_type": 0 for RTMP, 1 for WHIP
"name": Name of the Ingress,
"room_name": Name of the room to connect to,
"participant_identity": Unique identity for the room participant the Ingress service will connect as,
"participant_name": Name displayed in the room for the participant
}On success, livekit-cli will return the unique id for the Ingress.
It is possible to get details on all created Ingress with the list-ingress command:
livekit-cli list-ingressIn particular, this will return the RTMP url WHIP endpoint to use to setup the encoder.
The Ingress service can be run natively on any platform supported by GStreamer.
The Ingress service is built in Go. Go >= 1.18 is needed. The following GStreamer libraries and headers must be installed:
On MacOS, these can be installed using Homebrew by running mage bootstrap.
Build the Ingress service by running:
mage buildTo run against a local LiveKit server, a redis server must be running locally. All servers must be configured to communicate over localhost. Create a file named config.yaml with the following content:
log_level: debug
api_key:
api_secret:
ws_url: ws://localhost:7880
redis:
address: localhost:6379On MacOS, if GStreamer was installed using Homebrew, the following environment must be set in order to ensure that GStreamer can load all its plugins:
export DYLD_LIBRARY_PATH=/opt/homebrew/libThen to run the service:
ingress --config=config.yamlIf starting an Ingress fails with a GStreamer error such as Failed to load libsoup library or no such element factory "souphttpsrc, try deleting your GStreamer plugin registry with:
rm -rf ~/.cache/gstreamer-1.0/To run against a local LiveKit server, a Redis server must be running locally. The Ingress service must be instructed to connect to LiveKit server and Redis on the host. The host network is accessible from within the container on IP:
Create a file named config.yaml with the following content:
log_level: debug
api_key:
api_secret:
ws_url: ws://host.docker.internal:7880 (or ws://172.17.0.1:7880 on linux)
redis:
address: host.docker.internal:6379 (or 172.17.0.1:6379 on linux)In order to be able to use establish WHIP sessions over UDP, the container must be run with host networking enabled.
Then to run the service:
docker run --rm \
-e INGRESS_CONFIG_BODY="`cat config.yaml`" \
-p 1935:1935 \
-p 8080:8080 \
--network host \
livekit/ingressLiveKit Ecosystem
Agents SDKsPython · Node.js
LiveKit SDKsBrowser · Swift · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32 · C++
Starter AppsPython Agent · TypeScript Agent · React App · SwiftUI App · Android App · Flutter App · React Native App · Web Embed
UI ComponentsReact · Android Compose · SwiftUI · Flutter
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
ResourcesDocs · Docs MCP Server · CLI · LiveKit Cloud
LiveKit Server OSSLiveKit server · Egress · Ingress · SIP
CommunityDeveloper Community · Slack · X · YouTube
No open issues yet, or sync has not completed.