icecasttranscodinginternet-radioliquidsoap

How to optimize liquidsoap?


I want to relay ~40 radio with Icecast and transcode them to 3 bitrates(32,64,128)

Relay all radio and transcoding them to 32 bitrate working good, but on 64, 128 doesn't work

Liquidsoap logs:

2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.04s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.02s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.
2015/07/24 11:36:56 [:3] Buffer overrun: Dropping 0.03s.

Liquidsoap config:

set("buffering.kind","raw")
set("log.file", true)

def my_input(url) =
    mksafe(input.http(buffer=5., max=20., url));
end

def outputs(name, mount, input) =
    output.icecast(
    %mp3(bitrate=32, samplerate=22050, stereo=false),
    ******
    mean(input))

    output.icecast(
    %mp3(bitrate=64,samplerate=44100,stereo=true),
    ******
    input)

    output.icecast(
    %mp3(bitrate=128,samplerate=44100,stereo=true),
    ******
    input)

end

url = "http://localhost:8000/radio1"
input = my_input(url)
outputs("Radio1", "radio1", input)

#..............

url = "http://localhost:8000/radio40"
input = my_input(url)
outputs("Radio40", "radio40", input)

Icecast limits:

enter image description here

Server info:

6 cores(average load 40%)
6GB RAM

htop screen: enter image description here


Solution

  • Unfortunately, the load in this case is for the codec and there isn't a lot you'll be able to do to reduce it. Split your transcoding across multiple servers.

    For what it's worth, I can usually get 12 streams transcoded on the cheapest Digital Ocean box available. If you're not already using cheap VPS hosting for this, I recommend it! Just be sure to monitor CPU with something like New Relic and move to a new host should they cut into the cycles you're allocated. Your codec needs a constant availability of CPU to keep buffers full.

    Also, I don't know what your source stream is but I highly recommend starting with a lossless source. Lossy codecs reduce quality and using more than one of them in a chain reduces it further.