Try   HackMD

nginx rtmp server

手機推流 > nginx rtmp server > OBS拉流 > OBS推到實況平台

nginx.conf

worker_processes 1; error_log logs/rtmp_error.log debug; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live1 { live on; publish_notify on; record off; } } }
  • 手機推到: rtmp://127.0.0.1:1935/live1/ (在外面時請把ip改成外網可連到的實體ip)
    • 串流碼: streamkey001
  • OBS影片播放器拉流(或用VLC播放器)
    • 拉流網址: rtmp://127.0.0.1:1935/live1/streamkey001

一推多平台

nginx.conf

worker_processes 1; error_log logs/rtmp_error.log debug; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live2 { live on; publish_notify on; meta copy; push rtmp://site1/streamkey; push rtmp://site2/streamkey; push rtmp://site3/streamkey; } } }
  • OBS推流網址: rtmp://127.0.0.1:1935/live2/

以上兩者整合使用

nginx.conf

worker_processes 1; error_log logs/rtmp_error.log debug; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live1 { live on; publish_notify on; record off; } application live2 { live on; publish_notify on; meta copy; push rtmp://site1/streamkey; push rtmp://site2/streamkey; push rtmp://site3/streamkey; } } }
  • 手機推到nginx rtmp server
    • 推流網址: rtmp://127.0.0.1:1935/live1/ (在外面時請把ip改成外網可連到的實體ip)
    • 串流碼: streamkey001
  • OBS or 影片播放器拉流
    • 拉流網址: rtmp://127.0.0.1:1935/live1/streamkey001
  • OBS推流到多平台
    • 推流網址: rtmp://127.0.0.1:1935/live2/

補充說明

1

改完nginx.conf設定記得要重啟nginx設定值才會生效

2

nginx.conf裡的worker_processes 1;
如果預設值的1個processes算力不夠用,可以試看看調高到2~4以上
通常是發生在一推多平台推太多個導致單processes算力不夠力

改法像是這樣:
worker_processes 4;

不然也可以調成auto看看
worker_processes auto;

這個參數通常是調比CPU執行緒數量低
假設CPU是8核8緒 就是調到8以下
假設CPU是8核16緒 就是調到16以下
而且還要多預留算力給同電腦下的遊戲,OBS,視訊之類的使用

資料來源

tags: OBS, nginx, rtmp