1.1.7 • Published 1 month ago
rtsp-to-hls-server v1.1.7
RTSP Stream to HLS Server Library
This Node.js library allows you to easily stream RTSP video to a HLS server. It supports H264 and is highly optimized and customizable.
Installation
To install this library, simply run:
npm install rtsp-to-hls-server
Usage
This code initializes a new instance of the Stream class with the specified parameters. The Stream class represents a video stream and is responsible for starting and stopping the stream.
This is a really simple abstraction for starting ffmpeg and use it with your own hls server
import * as HlsStream from "rtsp-to-hls-server";
const stream = await new HlsStream({
name: `${port}`,
ip: body.ip,
streamUrl: rtspURL,
streamMetadata: streamData,
channel: channel,
tempDir: tempPath,
shouldStop: true, //boolean variable to indicate if timeout should kill the stream
killTimeout: 10, // value in minutes for timeout to kill the stream
customLogger: (message: string) => this.logger.log(message),
ffmpegOptions: {
"-c:v": "h264_amf",
"-r": 25,
"-threads": 1,
"-flush_packets": 1,
"-reconnect": 5,
"-reconnect_at_eof": 1,
"-timeout": 60,
"-reconnect_streamed": 1,
"-fflags": "nobuffer",
"-rtsp_transport": rtspTransport ? rtspTransport : "tcp",
},
});
License
This library is licensed under the MIT License.