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.
- Host: GitHub
- URL: https://github.com/mgthetrain/nginx-hls-sample
- Owner: MGTheTrain
- Created: 2023-11-19T21:33:42.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-07T18:06:37.000Z (over 2 years ago)
- Last Synced: 2024-01-07T19:23:52.636Z (over 2 years ago)
- Topics: hls, live-streaming, nginx, sample
- Language: HTML
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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).