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";
}
}
}
@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