Giter Site home page Giter Site logo

m1k1o / hls-restream Goto Github PK

View Code? Open in Web Editor NEW
33.0 8.0 22.0 47 KB

Restream live content as HLS using ffmpeg in docker. Also with NVIDIA GPU hardware acceleration.

Dockerfile 2.70% Shell 92.10% HTML 5.20%
docker hls-live-streaming ffmpeg restream hls-restream nvidia-cuda

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

hls-restream's People

Contributors

ilteoood avatar m1k1o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hls-restream's Issues

Hla input stream stuck on lowest quality

Hi there,

This tool is working great except I am trying to use an input stream which is hls and only when get it restreamed at the lowest quality (there are 4 or 5 streams within the hls, last one being the 1080 one. Is it something I am doing wrong or is there a way to force the restream of the 1080 stream?

Stop Streams when not needed

This is a simple project which does what i want.
But is it somehow possible to stop ffmpeg if no user is connected to the stream anymore?

question ???

how much traffic or users can handle digital ocean 12$ / moth can you estimate please ?

SSL

Hello bro,

  • if you have some time please add SSL to this project .

unable to build

i'm getting build error.

this is my output:-

Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/*.bin || true'

exec ./entrypoint.sh: no such file or directory

Brand new install. Getting this error.

docker-compose up --build
[+] Building 0.7s (13/13) FINISHED
 => [hls internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [hls internal] load build definition from Dockerfile                                                           0.0s
 => => transferring dockerfile: 750B                                                                               0.0s
 => [hls internal] load metadata for docker.io/library/ubuntu:latest                                               0.6s
 => [hls 1/8] FROM docker.io/library/ubuntu@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f5  0.0s
 => [hls internal] load build context                                                                              0.0s
 => => transferring context: 451B                                                                                  0.0s
 => CACHED [hls 2/8] WORKDIR /usr/src                                                                              0.0s
 => CACHED [hls 3/8] RUN set -eux; apt-get update;     apt-get install -y --no-install-recommends ffmpeg nginx su  0.0s
 => CACHED [hls 4/8] RUN mkdir -p /var/log/supervisor;     mkdir -p /var/www/html;     groupadd --gid 1000 user;   0.0s
 => CACHED [hls 5/8] COPY supervisord.conf entrypoint.sh ./                                                        0.0s
 => CACHED [hls 6/8] COPY profiles profiles                                                                        0.0s
 => CACHED [hls 7/8] COPY player.html /var/www/html/index.html                                                     0.0s
 => CACHED [hls 8/8] COPY nginx.conf /etc/nginx/sites-enabled/default                                              0.0s
 => [hls] exporting to image                                                                                       0.0s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:1bbca30320e1110f37dc8ad80ade66e588666a00ec96584f672ba637db951a0c                       0.0s
 => => naming to docker.io/library/hls-restream-hls                                                                0.0s
Attaching to hls
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory
hls  | exec ./entrypoint.sh: no such file or directory

transcoding_hd

which command to activate transcoding_hd?

   test    http://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8 transcoding_hd

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.