Anybody guide me to set up of HLS re-streaming on Nginx-rtmp server. (like rtmp edge stream)
If you want to produce HLS streams in addition to RTMP then you just need to do something like this:
server {
listen 1935;
application app {
live on;
push rtmp://localhost:1935/hls-live;
}
application hls-live {
live on;
hls on;
hls_fragment_slicing aligned;
hls_path /var/www/html/live;
}
}
The hls-live application could be on any number of "edge" servers. So you could do:
push rtmp://hls-edge1.example.com:1935/hls-live;
push rtmp://hls-edge2.example.com:1935/hls-live;
push rtmp://hls-edge3.example.com:1935/hls-live;
The hls_fragment_slicing aligned option is important so that each edge server produces the same MPEG-TS chunks.
Better solution will be to proxy_cache requests, because push will force
edge servers to mux rtmp into hls again on every edge. It's using resources
so it's not effective.
15 sie 2015 19:01 "Ben Wilber" [email protected] napisał(a):
If you want to produce HLS streams in addition to RTMP then you just need
to do something like this:server {
listen 1935;application app { live on; push rtmp://localhost:1935/hls-live;}
application hls-live {
live on;
hls on;
hls_path /var/www/html/live;
}
}The hls-live application could be on any number of "edge" servers. So you
could do:push rtmp://hls-edge1.example.com:1935/hls-live;
push rtmp://hls-edge2.example.com:1935/hls-live;
push rtmp://hls-edge3.example.com:1935/hls-live;—
Reply to this email directly or view it on GitHub
https://github.com/arut/nginx-rtmp-module/issues/668#issuecomment-131400781
.
I have tried below configuration(proxy_store ), for me it is not working.. I`m willing to know what approach did you used with proxy_cache requests .. Thank You
location / {
root /ramcache;
try_files $request_uri @proxy_origin;
}
location ~* .(m3u8)$ {
proxy_cache off;
expires -1;
proxy_pass http://originServerList;
}
location ~* .(ts|trp)$ {
root /ramcache;
try_files $request_uri @proxy_origin;
}
location @proxy_origin {
resolver 8.8.8.8;
proxy_pass http://originServerList;
proxy_temp_path "/ramcache/tmp";
proxy_store "/ramcache/$request_uri";
proxy_store_access user:rw group:rw all:r;
proxy_method GET;
proxy_set_header Host $host;
}
Source:: https://groups.google.com/forum/#!topic/nginx-rtmp/rx_54CBKv8Y
Try: proxy_store "/ramcache$request_uri"; - without leading /.
And you probably dont need separate locations for files, just disable cache for all of them.
location / {
root /ramcache;
proxy_cache off;
expires -1;
try_files $request_uri @proxy_origin;
}
location @proxy_origin {
internal;
resolver 8.8.8.8;
proxy_pass http://originServerList;
proxy_temp_path "/ramcache/tmp";
proxy_store "/ramcache$request_uri";
proxy_store_access user:rw group:rw all:r;
proxy_method GET;
include proxy_params;
}
You need separate locations, because m3u8 shouldn't be cached. (You can
cache m3u8 but you really need to know what are you doing and it's better
to not cache without custom code).
I'll be back home at sunday and then I will send you my config.
21 sie 2015 16:05 "Sergey" [email protected] napisał(a):
Try: proxy_store "/ramcache$request_uri"; - without leading /.
And you probably dont need separate locations for files, just disable
cache for all of them.location / {
root /ramcache;
proxy_cache off;
expires -1;try_files $request_uri @proxy_origin;}
location @proxy_origin {
internal;
resolver 8.8.8.8;
proxy_pass http://originServerList;
proxy_temp_path "/ramcache/tmp";
proxy_store "/ramcache$request_uri";
proxy_store_access user:rw group:rw all:r;
proxy_method GET;
include proxy_params;
}—
Reply to this email directly or view it on GitHub
https://github.com/arut/nginx-rtmp-module/issues/668#issuecomment-133435934
.
And that's why I suggested to disable cache at all.
Caching ts files makes sense for edge (without caching .ts you will proxy
every request to origin and not take off the load from it).
21 sie 2015 16:17 "Sergey" [email protected] napisał(a):
And that's why I suggested to disable cache at all.
—
Reply to this email directly or view it on GitHub
https://github.com/arut/nginx-rtmp-module/issues/668#issuecomment-133439991
.
But you already have proxy_store for files. They will be readed after original proxied, no?
But its not working as expected.. it stores playlist(m3u8) file too ..
Thanks..
Date: Fri, 21 Aug 2015 07:05:14 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [nginx-rtmp-module] Is there any option for HLS re-streaming on Nginx-rtmp module like rtmp edge server ? (#668)
Try: proxy_store "/ramcache$request_uri"; - without leading /.
And you probably dont need separate locations for files, just disable cache for all of them.
location / {
root /ramcache;
proxy_cache off;
expires -1;
try_files $request_uri @proxy_origin;
}
location @proxy_origin {
internal;
resolver 8.8.8.8;
proxy_pass http://originServerList;
proxy_temp_path "/ramcache/tmp";
proxy_store "/ramcache$request_uri";
proxy_store_access user:rw group:rw all:r;
proxy_method GET;
include proxy_params;
}
—
Reply to this email directly or view it on GitHub.
better i have to try proxy_cache, rather then proxy_store, Nginx does`t control expiration on proxy_store..
proxy_cache is a must. Forgot about this issue, tomorrow I'll clean up my
config of my lua code and show you a way to make edge.
28 sie 2015 18:27 "Linuxbot" [email protected] napisał(a):
better i have to try proxy_cache, rather then proxy_store, Nginx does`t
control expiration on proxy_store..—
Reply to this email directly or view it on GitHub
https://github.com/arut/nginx-rtmp-module/issues/668#issuecomment-135825137
.
Using demo playlist for FlasHLS player demo
proxy_cache_path /var/www/hls-test1/cache levels=1:2 keys_zone=hls-test1-cache:8m max_size=1000m inactive=600m;
server {
listen 80;
server_name hls-test1.domain.com
root /var/www/hls-test1;
proxy_temp_path /var/www/hls-test1/temp;
location / {
proxy_pass http://www.streambox.fr;
add_header "X-Hls-Cache-Status" "Fresh data";
}
location ~* .(ts|trp)$ {
proxy_pass http://www.streambox.fr;
proxy_cache hls-test1-cache;
proxy_cache_valid 200 10m;
proxy_cache_valid 404 5s;
add_header "X-Hls-Cache-Status" "Cached TS";
}
}
proxy_cache_valid time values are for example (10m, 5s) and should be matching event data.
Awesome.. Thank you @misiek08
Most helpful comment
Using demo playlist for FlasHLS player demo
proxy_cache_valid time values are for example (10m, 5s) and should be matching event data.