For a good number of months I’ve been working on creating a very basic RTMP live video streaming server. Now that I have a very, very basic usable system (after several complete rewrites) I wanted to release it out into the world in case anyone was interested at least.
The libraries are MIT licensed with source code at https://github.com/KallDrexx/elixir-media-libs. The core projects (and hex packages) are:
- amf0 - Library with functions for serializing and deserializing data in the AMF0 encoding format. It’s not 100% complete on the spec but it has the core types implemented.
- rtmp_handshake - Library that allows systems to perform an RTMP handshake, both as client and a server. It supports both simple and digest handshake formats.
- rtmp_session - An abstraction that represents a single peer in an RTMP connection. This is essentially the core brain of an RTMP peer where you give it TCP packets and it spits out events and tcp responses. Right now it is only programmed to work as a server, but the client portion is on my todo list.
- gen_rtmp_server - Behavior that makes easy to create your own RTMP server and provides callbacks for your own custom application logic to respond to RTMP events
These have all been put together to create a simple RTMP server. This server allows connections via any stream key and application name for publishing and video playback. It is dead simple but it works well enough to watch video from. I definitely would not say it’s production ready yet in any capacity.
The long, long term goal of this project is to create a completely free and open source alternative to Wowza, and the like. RTMP is just the start, I want to support both input and output of RTSP, RTP, Mpeg-TS, HLS and Dash streams (a secondary goal is to get this to a usable state to make an NVR for my home IP cameras as well).
My next high level steps (outside bug fixing) on the project are:
- Allow saving an RTMP stream into HLS fragments with manifest
- Create an
gen_rtmp_clientabstraction to support relaying video out to a secondary RTMP server
- Add libraries to parse FLV and MP4 files, and serve them to an RTMP player (vod support)
- Start work on more complex media server