Flussonic

Importing m3u list to Flussonic

Flussonic can’t import M3U lists, but community write a simple Python script that converts m3u lists to Flussonic config file :+1:

In the initial setup, you may need to create a large number of streams. For example, this can be a list of the multicast groups or other HTTP MPEG-TS / HLS / RTMP sources.

In the interface of Flussonic there is no such function, but Flussonic provides an API for import and a simple configuration file format. Using a small python script you can convert the m3u playlist to Flussonic configuration and then insert it to /etc/flussonic/flussonic.conf. Or import streams to multiple servers by using curl and HTTP API.

At first, download script m3u_to_flussonic.py from gist.github.com:

wget -O m3u_to_flussonic.py https://gist.githubusercontent.com/klyushkov/bf95dcf66ba99ba9a5d8e5eb71db75ae/raw/f998977e3596c11129f31470936a58145a68e180/m3u_to_flussonic.py

Then run it using python (most distros comes with installed python, if not use following command apt install -y python-minimal)

python m3u_to_flussonic.py example1.m3u

As a result, you should obtain the following output:

root@flussonic:~# python m3u_to_flussonic.py example1.m3u
stream _BBC_World {
  url tshttp://example.com/stream/to/video2;
}
stream _CNN_International {
  url tshttp://example.com/stream/to/video2;
}
stream Arirang {
  url tshttp://example.com/stream/to/video3;
}
stream ORT {
  url tshttp://example.com/ort/mpegts;
}
stream ORT_HLS {
  url hls://example.com/ort/index.m3u8;
}
stream stream6 {
  url hls://example.com/streamwithoutname/video.m3u8;
}
stream RTMP_stream {
  url rtmp://example.com/static/stream;
}

Example on other m3u playlist:

root@flussonic:~# python m3u_to_flussonic.py example2.m3u
stream stream1 {
  url udp://239.255.0.1:5500;;
}
stream stream2 {
  url udp://239.255.0.2:5500;;
}
stream stream3 {
  url udp://239.255.0.3:5500;;
}
stream stream4 {
  url udp://239.255.0.4:5500;;
}
stream stream5 {
  url udp://239.255.0.5:5500;;
}

Copy this configuration (output from last command) to etc/flussonic/flussonic.conf file, then reload config with /etc/init.d/flussonic reload

You can apply new config via API. It may be useful if you want to push config to few servers:

root@flussonic:~# curl -u flussonic:letmein! --data-binary "$(python m3u_to_flussonic.py example2.m3u)" http://flussonic:8080/flussonic/api/config/stream_create
{"success":true}

Where flussonic:letmein! - is login and password of your Flussonic instance, example1.m3u - file from which you want to import streams, http://flussonic:8080 - URL of your Flussonic server. {"success":true} means that the import was successful.

m3u_to_flussonic.py can work with remote files via http://:

root@flussonic:~# python m3u_to_flussonic.py http://example.com/example2.m3u
<...>

You can train on this example playlists if you don’t have own m3u playlist:

example1.m3u

#EXTM3U
#EXTINF:0 tvg-name="BBC" audio-track="eng" tvg-logo="http://example.com/BBC.png", BBC World
http://example.com/stream/to/video2
#EXTINF:0 tvg-name="CNN" audio-track="rus" group-title="News", CNN International
http://example.com/stream/to/video2
#EXTINF:0,Arirang
http://example.com/stream/to/video3
#EXTINF:-1,ORT
http://example.com/ort/mpegts
#EXTINF:-1,ORT_HLS
http://example.com/ort/index.m3u8
http://example.com/streamwithoutname/video.m3u8
#EXTINF:-1,RTMP_stream
rtmp://example.com/static/stream

example2.m3u

udp://239.255.0.1:5500
udp://239.255.0.2:5500
udp://239.255.0.3:5500
udp://239.255.0.4:5500
udp://239.255.0.5:5500