HLSProxy is a HLS stream (HTTP Live Stream) proxier that mirrors a hls server.
HLSProxy works by caching the original segments from a HLS server, then generates new playlist (.m3u8) file.
Any mediaplayer with HLS support can be used to play the stream from your own server!
Yes, HLSProxy can handle serveral streams parallelly. This depends on your internet speed of course!
First create a list of HLSProxy like so (see Program.cs
):
var sources = new List<HLSProxy> { new HLSProxy("Resources/<website>", 10, "http://<website>/master.m3u8"), ... };
Warning: If you pass window size of 0 or less, it will never delete any segments from the cache.
Then pass sources
to a stream handler var handler = new HLSHandler(sources).Run();
If you don't want the main thread to exit, simply call Wait()
on handler
By default, the Kestrel will prevent the main thread from exiting so you don't need to call
Wait()
The stream will be available at Resources/TRT WORLD
in the root folder.
Use VLC or any supported mediaplayer to stream http://localhost:5000/Resources/<website>/playlist.m3u8
.
Caches HLS segments from a single source.
The segments are automatically downloaded when a new segment is available.
public HLSProxy(string CacheFolder, int WindowSize, string indexUrl)
CacheFolder : The folder to cache segments to
WindowSize : Contraints cache size
indexUrl : the full URL to the m3u8 file
Schedules HLSProxy on multiple websites.
The HLSHandler schedules jobs by adding a time padding between each.
This makes sure that all jobs don't do network request at same time (prevents network overload).
public HLSHandler(List<HLSProxy> HLSProxies)
HLSProxies : A list of HLSProxy classes