Giter Club home page Giter Club logo

rtxp-to-hls's Introduction

RTxP to HLS Realtime Stream Converter

This service will convert RTMP/RTSP stream into HLS stream that we can play directly using HTML 5 video element. The conversion is done by using FFMpeg with hardcoded transcoding profile (feel free to set the params as requirements).

The FFMpeg will run as child process (spawn) and detached, the code has minimum stream id checking, what is mean that request to convert the same source url will be ignored if the previous conversion for the same source url is still active.

The conversion will stop if the source stream ended or closed. However the latest cache will still be available unless it replaced.

Running in Development

Clone this repository and run:

npm install

Before we run the project, create one .env file in the root of the project and configure this value:

STREAM_API_URL=<http://localhost:3005 or use hosting url in production>
FFMPEG_PATH=<path to ffmpeg i.e. /usr/bin/ffmpeg>

To run this project in the development:

npm run dev

The development server will run at http://localhost:3005

Testing Endpoints

Convert Stream

curl -L -X POST 'http://localhost:8006/stream/convert' -H 'Content-Type: application/json' -d '{ "url": "<rtmp://stream-url or rtsp://stream-url>" }'

Example response:

{
    "url": "http://localhost:3005/static/6f206b6cd45ac9a2244f7ae9c57c28b3/stream.m3u8"
}

Stop Conversion

curl -L -X POST 'http://localhost:8006/stream/stop' -H 'Content-Type: application/json' -d '{ "url": "<rtmp://stream-url or rtsp://stream-url>" }'

Example response:

{
    "success": "true"
}

Running in Production

It's highly recommended to run this service inside docker container, and here is the minimum required syntax to run:

docker run --name rtxp-to-hls -p 80:80 -d -e STREAM_API_URL=http://where-am-i-hosted.com rtxp-to-hls

Although the service is possible to run without binding a volume, it's highly recommender if you bind one, i.e:

docker run --name rtxp-to-hls --mount type=bind,source=/dedicated/volume,target=/app/public -p 80:80 -d -e STREAM_API_URL=http://where-am-i-hosted.com rtxp-to-hls

rtxp-to-hls's People

Contributors

dependabot[bot] avatar feedsbrain avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

tommyteavee

rtxp-to-hls's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.