Code Monkey home page Code Monkey logo

hls-restream's Introduction

hls-restream

Restream live content as HLS using ffmpeg in docker.

Usage

You need to have docker & docker-compose installed.

  1. Clone this repository:
git clone https://github.com/m1k1o/hls-restream
cd hls-restream
  1. Modify docker-compose.yml and add your own sources:
version: "3.4"
services:
  hls:
    build: "./"
    container_name: "hls"
    restart: "always"
    tmpfs:
      - "/var/www/html:mode=777,size=128M,uid=1000,gid=1000"
    ports:
      - "80:80"
    environment:
      PROFILE: passthrough
      SOURCES: |
        # SD Channels:
        ch1     rtsp://192.168.1.5:554/ch1
        ch2     rtsp://192.168.1.5:554/ch2
        # HD Channels:
        ch1_hd  http://192.168.1.6/stream/channelid/8967896?profile=pass
        ch2_hd  http://192.168.1.6/stream/channelid/4969639?profile=pass

Profiles can you find in profiles/ folder.

  • passthrough - default, no transcoding.

H264 adaptive bitrate transcoding:

  • abr_transcoding_sd - 360p and 480p
  • abr_transcoding_hd - 360p, 480p and 720p
  • abr_transcoding_hd_1080p - 360p, 480p, 720p and 1080p

H264 transcoding:

  • transcoding_hd - 720p only
  • transcoding_sd - 480p only
  1. Start docker compose (run this everytime you modify stream sources):
docker-compose up -d --build
  1. Watch streams:
http://localhost/ch1.m3u8
http://localhost/ch2.m3u8
http://localhost/ch1_hd.m3u8
http://localhost/ch2_hd.m3u8

In case of error, troubleshoot:

docker logs hls
docker exec -it hls sh -c 'cd /var/log/supervisor && /bin/bash'

NVIDIA GPU hardware acceleration

You will need to have nvidia-docker installed.

docker build -t hls_nvidia -f Dockerfile.nvidia .
docker run -d --gpus=all \
  --name hls_nvidia \
  --tmpfs /var/www/html:mode=777,size=128M,uid=1000,gid=1000 \
  -p 80:80 \
  -e 'PROFILE=transcoding_sd' \
  -e 'SOURCES=
        # SD Channels:
        ch1     rtsp://192.168.1.5:554/ch1
        ch2     rtsp://192.168.1.5:554/ch2
        # HD Channels:
        ch1_hd  http://192.168.1.6/stream/channelid/8967896?profile=pass
        ch2_hd  http://192.168.1.6/stream/channelid/4969639?profile=pass
  ' \
  hls_nvidia

Supported inputs

Input codec will be automatically determined from given stream. Please check your graphic card's supported codec and maximum concurrent sessions here.

Codec CUVID Codec Name
h264 h264_cuvid H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
hevc hevc_cuvid H.265 / HEVC
mjpeg mjpeg_cuvid Motion JPEG
mpeg1video mpeg1_cuvid MPEG-1 video
mpeg2video mpeg2_cuvid MPEG-2 video
mpeg4 mpeg4_cuvid MPEG-4 part 2
vc1 vc1_cuvid SMPTE VC-1
vp8 vp8_cuvid On2 VP8
vp9 vp9_cuvid Google VP9

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.