An open API service indexing awesome lists of open source software.

https://github.com/mgthetrain/nginx-hls-sample

Sample repository demonstrating HLS streaming with nginx.
https://github.com/mgthetrain/nginx-hls-sample

hls live-streaming nginx sample

Last synced: about 1 year ago
JSON representation

Sample repository demonstrating HLS streaming with nginx.

Awesome Lists containing this project

README

          

# nginx-hls-sample

## Table of Contents

- [Summary](#summary)
- [References](#references)
- [How to use](#how-to-use)

## Summary

Sample repository demonstrating HLS streaming with nginx

## References

[Main reference](https://www.codeinsideout.com/blog/pi/stream-ffmpeg-hls-dash/#create-video-chunks)

## How to use

### Build docker image and run nginx docker container

```
# Build
sudo docker build -t nginx-video-streaming:stable .
# Run on Unix systems
sudo docker run -v /dev/shm/hls:/usr/share/nginx/html/hls \
-v $(pwd)/assets:/usr/share/nginx/html \
-p 8080:80 -d nginx-video-streaming:stable
```

### Record new video and audio segments with ffmpeg

```
# HLS with h264 (video codec) and aac (audio codec) on Unix systems

sudo mkdir -vp /dev/shm/hls
sudo ffmpeg -y -f v4l2 -framerate 30 -i /dev/video0 -f alsa -i hw:0 -c:v libx264 -preset veryfast -tune zerolatency -pix_fmt yuv420p -b:v 1500k -c:a aac -b:a 64k -ar 44100 -f hls -hls_time 1 -hls_list_size 30 -hls_flags delete_segments /dev/shm/hls/live.m3u8
```

### View results

Visit `localhost:8080/hls-stream.html` in a browser of choice (e.g. Safari, Chrome, Firefox).