Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active April 16, 2022 11:26
Show Gist options
  • Save unitycoder/62e2fca5bd00a3b907cfe0a95d04f62d to your computer and use it in GitHub Desktop.
Save unitycoder/62e2fca5bd00a3b907cfe0a95d04f62d to your computer and use it in GitHub Desktop.
Setting up Live Video Stream Server on Windows 10 (RTPM + HLS + OBS)
from http://zqdevres.qiniucdn.com/data/20170907091103/index.html
- download ngingx with RTPM module http://nginx-win.ecsds.eu/download/ *nginx 1.7.12.1 Lizard.zip
- unzip
- create start.bat script
@echo off
title Start Stream
cd /d "C:\nginx"
start nginx
exit
- create close.bat script
@echo off
title Stop Stream
cd /d "C:\nginx"
nginx.exe -s stop
exit
- use/edit config file below, place it under /conf/
Streaming with OBS to rtmp
- target rtmp://127.0.0.1/live/
- view from: rtmp://127.0.0.1/live/mystreamkey
Streaming with OBS to hls
- target http://127.0.0.1/live
- http://127.0.0.1/hls/mystreamkey.m3u8
---------------------------------------------
resources
- using ffmpeg https://forum.unity.com/threads/what-is-the-preferred-video-byte-stream-format-for-the-video-object-in-5-6.472438/
- https://www.quora.com/How-can-I-stream-a-game-to-a-friend-with-minimal-delay
#user nobody;
# multiple workers works !
worker_processes 2;
#pid logs/nginx.pid;
events {
worker_connections 8192;
# max value 32768, nginx recycling connections+registry optimization =
# this.value * 20 = max concurrent connections currently tested with one worker
# C1000K should be possible depending there is enough ram/cpu power
# multi_accept on;
}
rtmp {
server {
listen 1935;
allow play all;
chunk_size 4000;
application live {
live on;
allow publish all;
allow play all;
#enable HLS
hls on;
hls_path "X:/apps/nginx 1.7.12.1 Lizard/html/hls";
hls_fragment 3;
hls_playlist_length 60;
}
application hls {
live on;
hls on;
hls_path "X:/apps/nginx 1.7.12.1 Lizard/html/hls";
hls_fragment 15s;
}
}
}
http {
sendfile off;
tcp_nopush on;
directio 512;
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
root "x:/apps/nginx 1.7.12.1 Lizard/html";
}
location /hls {
# Disable cache
add_header Cache-Control no-cache;
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Allow-Headers' 'Range';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root "x:/apps/nginx 1.7.12.1 Lizard/html";
}
}
}
@alvarogalia
Copy link

Hi, i have an error: nginx: [emerg] the same path name "C:/Projects/Nginx/Lizard/html/hls" used in C:\Projects\Nginx\Lizard/conf/nginx.conf:40 and in C:\Projects\Nginx\Lizard/conf/nginx.conf:40
How to fix it?

You are using same path on 2 stream sections, ex rtmp and http.
Simply change one of them

@dannyanders
Copy link

Hi, i have an error: nginx: [emerg] the same path name "C:/Projects/Nginx/Lizard/html/hls" used in C:\Projects\Nginx\Lizard/conf/nginx.conf:40 and in C:\Projects\Nginx\Lizard/conf/nginx.conf:40
How to fix it?

You are using same path on 2 stream sections, ex rtmp and http.
Simply change one of them

Change it to what?

@alvarogalia
Copy link

Hi, i have an error: nginx: [emerg] the same path name "C:/Projects/Nginx/Lizard/html/hls" used in C:\Projects\Nginx\Lizard/conf/nginx.conf:40 and in C:\Projects\Nginx\Lizard/conf/nginx.conf:40
How to fix it?

You are using same path on 2 stream sections, ex rtmp and http.
Simply change one of them

Change it to what?

Change one of them to hls2 or something

@beaucasque
Copy link

I'm a super noob here but tech saavy. I need your knowledge my friend. I've placed the extracted "nginx 1.7.12.1 Lizard" folder on my C drive directly and the 2 bat files in it.. Is it where they should be placed? Is there any location I should change for them to locate the exe?

Also.. is there a port I should open in my firewall or router.

Thank you so much. Wish you are well!

@E3V3A
Copy link

E3V3A commented May 3, 2020

@alvarogalia @unitycoder
yeah, it would be good to post a conf that actually works. Also, what do yuo need to put inside the directories above named "hls" and "hls2" and "html"? Also where and how does the ffmpeg come into this picture?

@unitycoder
Copy link
Author

unitycoder commented May 4, 2020

@alvarogalia @unitycoder
yeah, it would be good to post a conf that actually works. Also, what do yuo need to put inside the directories above named "hls" and "hls2" and "html"? Also where and how does the ffmpeg come into this picture?

ok, i found the original conf file, seems that i had this part commented out (in case that helps)

            #enable HLS
#            hls on;
#            hls_path "X:/apps/nginx 1.7.12.1 Lizard/html/hls";
#            hls_fragment 3;

@unitycoder
Copy link
Author

ready-to-use RTSP / RTMP server and proxy that allows to read, publish and proxy video and audio streams
https://github.com/aler9/rtsp-simple-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment