Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A versatile source client: liquidsoap

Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients
View previous topic :: View next topic  
Author Message

PostPosted: Wed Jul 25, 2007 2:41 pm    Post subject: A versatile source client: liquidsoap Reply with quote

Hi all !

I'd like to present the source client we've been working on.
The specificity of liquidsoap is that, instead of building an ad-hoc solution for that single netradio, it was developped as a flexible tool in which you can combine as you like the features that you want. Hence, it has then been used successfully for several other netradios, for which the usual streaming tools did not suffice.

Describing an audio stream can be very complex: several inputs (file, stream relay, soundcard) can come into play, they can be combined in various ways (audio processing, mixing, track scheduling, fallbacks) and finally output in various ways (several servers/contents/formats). To make it easy without loosing in expressivity, liquidsoap configurations are written in its own little script language.

Let's say that you run an icecast server at host 'myhost' with source's passowrd being 'hackmeimcool', and you want to stream in Ogg/Vorbis a single looped file (Ogg/Vorbis, MP3, WAV, even AAC on the SVN version). Then this may do the job for you:
liquidsoap 'output.icecast.vorbis(host="myhost",password="hackmeimcool",mount="mystream.ogg",single("/path/to/my/file"))'

Now a more complex example.. Let's say that you want to stream all the files contained in a given directory, but relay a live stream as soon as it is available. At this point we need to introduce the notion of 'faillible source'. As we said before, the most important constraint when streaming is to be able to provide data at anytime. Liquidsoap checks this property when starting. For instance, playing a list of files is not safe unless you check that the files are local and valid first, etc..
So, the basic way to start a complex stream is to define a fallback source, which can be a single file (single files are checked at start-up):
emergency = single("/path/to/my/file")

Now define your playlist:
main = playlist("/path/to/playlist/directory")

At this point, you will also create the other source that you want to stream as soon as it is available:
live = input.http("http://host:8000/live.ogg")

For instance this source may be a live show streamed to this mountpoint.
Then you can write the full script, where /usr/bin/liquidsoap is the actual place for the binary:
 # Set logging to stdout
 set log.dir = "/tmp"
 set log.stdout = true

 # fallback source:
 emergency = single("/path/to/my/file")
 # Playlist:
 main = playlist("/path/to/playlist/directory")
 # Live stream
 live = input.http("http://host:8000/live.ogg")

 # Fallback from fallback source to playlist:
 # The "track_sensitive" parameter is set if we want to wait for the end of
 # current song before switching.
 source = fallback(track_sensitive=true,[main,emergency])
 # Fallback from playlist to live:
 # No track_sensitivity here since we do not want to cut the
 # begining of the live show... !
 source = fallback(track_sensitive=false,[live,source])

 # Output source to icecast:

The complete API is available here:

Let's finish instead with a poweruser example, which I hope will make you eager to learn more. Just copy-paste and run, there's nothing to edit!

set log.stdout = true
set log.dir = "/tmp"
set telnet = true

# Define a numbers source that plays a number station,
# or files from a queue that can be fed by the user using telnet.
numbers = input.http("")
numbers = strip_blank(length=2.,threshold=-30.,numbers)
numbers = fallback([normalize(request.queue(id="q")),numbers])

# We relay the Dolebraī libre music netradio.
# We wrap it in mksafe(), a predefined operator that plays
# blank when dolebrai fails to relay anything.
normal = mksafe(input.http(""))

# And now the magic :)
def smooth_add(~normal,~special)
  d = 1.  # delay before mixing after beginning of mix
  p = 0.2 # portion of normal when mixed =*.2.)
  fade.initial = fade.initial(duration=d*.2.)
  q = 1. -. p
  # We alias change_volume to c
  c = change_volume

# out is a predefined operator that
# outputs to your local sound card using libao

    copy-paste this to test.liq
    make it executable
    Run it !

Optionally you can test the following:
    telnet localhost 1234
    q.push /path/to/file
    And listen !

If you are interested in a very flexible way to design your audio stream, feel free to visit our website, drop us a mail at or join our IRC channel, #savonet on freenode. Liquidsoap is available in debian testing and unstable.
Back to top
Meswara Marco

Joined: 09 Apr 2011
Posts: 14

PostPosted: Tue May 24, 2011 10:44 am    Post subject: Reply with quote

i understand that liquidsoap is very versatile but i am a little unclear about somethings.

Note : i already have a working combo if icecast + ices0.4 for mp3 playlist streaming. I also have darkice for live audio streaming ( 'using mike in' of a laptop)

What i would like to do liquidsopa is be able to use the 'mike in' + having an mp3 file playing when i click on it using an mp3 player.

i understand that input.alsa() allows you to capture mike input but what is the function that allows you to take output of the mp3 player?

Am i making sense or did i get this wrong?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Source Clients All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber