RTSP

Hex.pmAPI Docs

RTSP built on top of Membrane RTSP to simplify streaming and serving media using RTSP protocol.

Client

The client depayload and parse received rtp packets. For list of supported media types: see supported media types

Usage

Start the client, connect and start receiving media

{:ok, session} = RTSP.start_link(stream_uri: "rtsp://localhost:554/stream", allowed_media_types: [:video])
{:ok, tracks} = RTSP.connect(session)
:ok = RTSP.play(session)

The current process will receive media stream:

{:rtsp, pid_or_name, {control_path, {sample, rtp_timestamp, key_frame?, timestamp_ms}}}

Server

There's two implementation for server side:

File Server

A simple rtsp server that serves local files.

{:ok, server} = RTSP.FileServer.start_link(port: 8554, files: [%{path: "/test", location: "/tmp/test.mp4"}])

You can play the stream using vlc or ffplay:

ffplay -i rtsp://localhost:8554/test

Server

The generic server implementation RTSP.Server only support publishing (streaming is planned).

Installation

The package can be installed by adding rtsp to your list of dependencies in mix.exs:

def deps do
  [
    {:rtsp, "~> 0.8.0"}
  ]
end

Supported Media Types

Codec Payloader Depayloader
H264 ✔️ ✔️
H265 ✔️ ✔️
AV1 ✔️ ✔️
VP8
VP9
MJPEG
AAC ✔️ ✔️
G711 ✔️ ✔️
Opus ✔️ ✔️
Vorbis
AC-3