Simple method for recording and broadcasting simultaneously. Sound card not necessarily required.
  • Hi all

    We came up with this hack as we wanted to be able to host Airtime in the cloud yet still be able to record and broadcast live shows and rebroadcast them at a later date.  You can also use this technique to record and rebroadcast simultaneously on a server in your studio with only one sound card.

    You need to install sox (available on most distributions).

    We modified Airtime to record from an icecast stream rather than from the sound card. Edit /usr/lib/airtime/pypo/bin/recorder.py  and comment out the ecasound command:

    #        command = "ecasound -f:%s,%s,%s -i alsa -o %s,%s000 -t:%s" % \
    #                                (ss, c, sr, filepath, br, length)

    Replace it with:

            command = "/usr/bin/sox -t ogg http://localhost:8000/studio.ogg -C6 %s trim 0 %s" % \
                                    (filepath, length)

    Obviously the stream needs to exist. You can use various tools (Mixx, Darkice, etc) to create it.  On our setup we used sox and oggfwd to pipe the sound from the sound card to icecast, e.g.: 

    /usr/bin/sox -q -r 44100 -t alsa plughw:1,0 -t ogg -C6 - | oggfwd -p -n "Studio" x.x.x.x 8000 hackme /studio.ogg
    (where x.x.x.x is localhost or the address of your machine).

    If you use this stream as the input for your Master source in Airtime, then it means you can record shows via the Airtime GUI (from the "line in") at the same time as they are broadcast.  

    We added a liquidsoap directive to /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq to push our new stream to the Master source:

    output.icecast(%vorbis,
      host = "localhost", port = 8001,
      password = "hackme", mount = "master",
      fallible=true,strip_blank(max_blank=10.,input.http("http://localhost:8000/studio.ogg")))

    There's probably better ways of doing this, but it works for us.  I hope it helps someone!