Skip to content

Eyevinn/live-encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eyevinn Live Encoding

Open Source Live Encoder based on ffmpeg and Shaka packager.

📖 Available as a Service 👀

PRs welcome made with hearth by Eyevinn Slack

Badge OSC

Live transcoding to HLS and optionally MPEG-DASH. Provides origin for CDN shield to pull streams as well as push to CDN origin.

Screenshot 1 Screenshot 2

Badge OSC

Requirements

  • ffmpeg and optionally Shaka packager installed

Installation / Usage

% npm install

Environment Variables

Variable Description Default value
PORT API port to bind and listen to 8000
ORIGIN_DIR  Location on disk where to write media segments and playlists /tmp/media
HLS_ONLY Only output HLS + TS true
RTMP_PORT RTMP port to bind and listen to 1935
STREAM_KEY RTMP streamkey stream
INPUT_URL Optional srt:// input URL. If set, the encoder dials this source in caller mode instead of listening for an RTMP publisher. If not set the RTMP listener is used
INPUT_DIAL_TIMEOUT Caller-mode dial deadline in seconds. If the source is never reached within this bound the encoder gives up and goes to error. A per-request timeout overrides it 300
OUTPUT_URL URL to upload media segments and playlists. If not set push to CDN is disabled

CDN Pull

Run encoder with media dir at /data

% ORIGIN_DIR=/data npm start

SRT input (caller mode)

By default the encoder listens for an incoming RTMP publisher. Set INPUT_URL to an srt:// URL to make the encoder dial a listener-mode SRT source in caller mode and pull the feed instead. This is useful for SRT contribution and for container platforms where no inbound UDP port can be exposed.

% ORIGIN_DIR=/data \
  INPUT_URL='srt://<host>:<port>?latency=200000&passphrase=<secret>&streamid=<id>' \
  npm start

Protocol knobs such as latency (microseconds), passphrase, streamid and connect_timeout (milliseconds) travel as query parameters on the URL and are handled by ffmpeg's srt reader directly, so any option the ffmpeg build supports can be used. While INPUT_URL is set the encoder stays in starting and retries the connection if the source is not up yet. It gives up and goes to error once the dial deadline is reached: the per-request timeout if supplied, otherwise INPUT_DIAL_TIMEOUT (default 300 seconds).

User Interface

Web user interface available at http://localhost:8000/

API

Start encoder:

% curl -X 'POST' \
  'http://localhost:8000/api/encoder' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "timeout": 0
}'

Get status:

% curl -X 'GET' \
  'http://localhost:8000/api/encoder' \
  -H 'accept: application/json'

If status is starting you can start pushing to the RTMP address rtmp://<your-host-ip>:1935/live/stream (where stream is the streamkey).

When status is running you can play the HLS from http://localhost:8000/origin/hls/index.m3u8

Top stop the encoder:

% curl -X 'DELETE' \
  'http://localhost:8000/api/encoder' \
  -H 'accept: application/json'

CDN Push (AWS Media Package)

Run encoder with media dir at /data

% ORIGIN_DIR=/data \
  OUTPUT_URL=https://<username>>:<password>@xxxxx.mediapackage.xxxx.amazonaws.com/in/v2/e82a0fc53d4b44ec89ac1a1fccd3a333/e82a0fc53d4b44ec89ac1a1fccd3a333/channel \
  npm start

Docker

Run Eyevinn live encoding as a Docker container where /tmp/media is a directory on your host.

% docker run --rm -d \
  -p 8000:8000 -p 1935:1935 \
  -v /tmp/media:/data \
  eyevinntechnology/live-encoding

Development

Start the API in development mode that restart server if file changes.

% DEBUG=1 npm run dev

API is then available at http://localhost:8000/api

Start the web application in development mode

% npm run dev:app

Then the web application is available at http://localhost:3000/ and will connect to the API on port 8000.

To then build the app run:

% npm run build:app

The output is placed in the folder out/ that is then served by the server.

Contributing

See CONTRIBUTING

License

This project is licensed under the MIT License, see LICENSE.

Support

Join our community on Slack where you can post any questions regarding any of our open source projects. Eyevinn's consulting business can also offer you:

  • Further development of this component
  • Customization and integration of this component into your platform
  • Support and maintenance agreement

Contact sales@eyevinn.se if you are interested.

About Eyevinn Technology

Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor. As our way to innovate and push the industry forward we develop proof-of-concepts and tools. The things we learn and the code we write we share with the industry in blogs and by open sourcing the code we have written.

Want to know more about Eyevinn and how it is to work here. Contact us at work@eyevinn.se!

About

Open Source Live encoder based on ffmpeg

Resources

License

Contributing

Stars

6 stars

Watchers

5 watching

Forks

Packages

 
 
 

Contributors

Languages