hls-server-encodingfixed
Simple HTTP middleware for serving HTTP Live Streaming (HLS) compatible media streams.
Disclaimer
The only difference from hls-server: a single undefined check has been added to prevent a crash.
Usage
First you need a compatible media stream (see Producing Streams)
Fast way:
8000
Detailed way:
var HLSServer = var http = var server = httpvar hls = server path: '/streams' // Base URI to output HLS streams dir: 'public/videos' // Directory that input files are storedserver
Producing Streams
HLS can only stream files that have been properly encoded and segmented. FFMPEG is great for this.
Here is how to do it with node-fluent-ffmpeg.
var ffmpeg = { // do something when encoding is done }
To create segments from an existing RTMP stream, use the following node-fluent-ffmpeg command. You can expect 20-50 seconds of latency, depending on hardware.
var ffmpeg = // host, port and path to the RTMP streamvar host = 'localhost'var port = '1935'var path = '/live/test' { // do something when stream ends and encoding finshes }
To publish from an RTMP client like OBS, use a RTMP server like rtmp-server-nodejs to echo the stream.
NOTE: Transcoding live streams is very CPU-intensive. Most consumer hardware won't be able to handle transcoding more than a few streams.
CLI Tool
This package includes a CLI tool that can be installed globally with npm install -g hls-server
.
To use, navigate to the directory where your .ts
files are stored and run hlsserver
in a command prompt. This will start a server on port 8000. (Use hlsserver --help
to see additional options.)