nginx-rtmp-module
nginx-rtmp-module copied to clipboard
Adaptive HLS relay server
Hi,
I'm trying to set up a system using two remote servers (both NginX compiled with RTMP module) for streaming video between them where network conditions may be "unstable" at times.
Is it possible to somehow "pull" an adaptive HLS stream from one server to the other (acting the latter also as a relay for their own private clients) and where the stream being transmitted between both servers is the best possible according to current network bandwidth (meaning one of the several available variants in the first server) ?
I read the available documentation but I didn't see nothing which indicated how to build such a system.
Thank you!
You can relay to your second server using RTMP and re-create the HLS files. See hls_fragment_slicing to make them output the same file(s). https://github.com/arut/nginx-rtmp-module/wiki/Directives#hls_fragment_slicing
In your situation you can user fragment hooks to send chunks to second server and just serve them to clients without any further config. You will need to write a daemon that receive from first nginx information about new fragment and send them in order to second server.
2015-12-15 18:19 GMT+01:00 nicktencate [email protected]:
You can relay to your second server using RTMP and re-create the HLS files. See hls_fragment_slicing to make them output the same file(s).
https://github.com/arut/nginx-rtmp-module/wiki/Directives#hls_fragment_slicing
— Reply to this email directly or view it on GitHub https://github.com/arut/nginx-rtmp-module/issues/740#issuecomment-164831511 .
Thank you for your answers, I can see how to send the HLS stream from the first server to the second, but I can't see how to make the adaptive part.
I mean, if I relay multiple streams from the first server to the second server (each stream with a different bitrate, but with the same live video content) how will the second server choose the stream that better adapts to current network bandwidth? Thanks!
Ah, currently no way to do this automatically. You will have to pick one manually.
Your script need to be smart enough. 16 gru 2015 16:22 "nicktencate" [email protected] napisał(a):
Ah, currently no way to do this automatically. You will have to pick one manually.
— Reply to this email directly or view it on GitHub https://github.com/arut/nginx-rtmp-module/issues/740#issuecomment-165139699 .
Ok, no automatic way... any guidelines for a 'smart script'? I guess it should:
- Measure the network status (ping time or something more accurate...?)
- Choose the adequate bitrate stream to send from server 1 to server 2 Makes sense?
Ping won't tell you much about link (because you can have great pings and slow connection), but your path is good. You need to periodically test connection and upload adequate stream.
2015-12-16 17:22 GMT+01:00 joelalmeida-pt [email protected]:
Ok, no automatic way... any guidelines for a 'smart script'? I guess it should:
- Measure the network status (ping time or something more accurate...?)
- Choose the adequate bitrate stream to send from server 1 to server 2 Makes sense?
— Reply to this email directly or view it on GitHub https://github.com/arut/nginx-rtmp-module/issues/740#issuecomment-165163037 .
Checkout: https://github.com/Viblast/dash-proxy https://github.com/Viblast/hls-proxy
http { 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 localhost; root /var/www/hls-test1; proxy_temp_path /var/www/hls-test1/temp; location / { proxy_pass http://ip-of-the-other-server; add_header "X-Hls-Cache-Status" "Fresh data"; } location ~* .(ts|trp)$ { proxy_pass http://ip-of-the-other-server; proxy_cache hls-test1-cache; proxy_cache_valid 200 10m; proxy_cache_valid 404 5s; add_header "X-Hls-Cache-Status" "Cached TS"; } } }
You have to tweak it, but it's more than nothing. Read the thread here
Checkout: https://github.com/Viblast/dash-proxy https://github.com/Viblast/hls-proxy
these python scripts will they work if my .mpd
or .m3u8
files are for multiple streams? My nginx configuration uses ffmpeg to create different quality streams depending on bandwidth