Goal: Stream from PC using OBS , receive stream with Nginx RTMP Module and output to viewers so that they can view the live stream both on PC and mobile. For that to happen, Nginx must output live stream with HLS.
My partner has set up the following Nginx file, but nothing occurs (it was done following this answer from stackoverflow –> answer )
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root /usr/build/nginx-rtmp-module;
}
# rtmp control
location /control {
rtmp_control all;
}
# Client (VLC etc.) can access HLS here.
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
application directo {
live on;
record off;
}
# You should send x.264/aac RTMP Stream via ffmpeg to this application
application hls {
allow play all;
live on;
hls on;
hls_path /tmp/hls;
}
}
}
And this is a capture of the OBS streaming configuration:
PC can view the stream just fine, but mobile can't.
Appreciate any input anyone may have.
Best Answer
I did test over ubuntu 16.04 LTS and it works with that following instructions:
Then you need to update the .conf file:
Conf file:
To start your nginx server (first kill it then start it):
To view stats of your nginx server: Where is the public ip of your server.
From your encoder such as OBS: Stream to your nginx server with that adress:
If you want to see your stream on VLC: Open a network stream then paste that:
You should see your stream.
If you want to host a HLS player where your viewers can watch your stream for free:
Put your http server in a screen session:
Access to your screen:
Then start your server:
Create your html page with Hls player:
and paste: Change that line with the correct ip
hls.loadSource('http://<ip_of_your_nginx_server>:8080/hls/stream.m3u8');
to your needsThen access to your player from a chrome browser and paste that link:
Now you do a complete streaming !!