Live streaming can be done independently from 3rd parties by using a streaming media server like Icecast and a source client for encoding and streaming to that server.
I'm using Icecast and oggfwd in combination with ffmpeg as source client to realize live streaming concerts at https://this.ven.uber.space/music/live/. Although there are many official source clients available, oggfwd seems to be the only solution when using JACK and encrypted connections with Transport Layer Security (TLS). Mixing and monitoring is done by ardour, hence the signal flow can be represented like this:
ardour ⇒ ffmpeg ⇒ oggfwd ⇒ icecast ⇒ listener
For this guide a running Icecast advanced configuration and a working FLOSS media studio setup for audio is assumed. General knowledge on how to install software and use a terminal in your GNU/Linux distribution is necessary, too.
Get ffmpeg and oggfwd package by using your distribution's package manager or compile from sources. You also need to have mpv installed to play waiting music as well as wget for triggering tasks via Icecast's Admin Interface.
To simply copy and paste the commands used in this guide, set the following environment variables to your needs. Most of the values depend on your Icecast basic setup. This is an example:
export CONCERT_TITLE="My streaming concert" export ARTIST_NAME="Just me" export HOSTNAME="icecast.example.org" export PORT="1234" export SOURCE_PASSWORD="secret-S0URC3-passwd" export STREAM_MOUNTPOINT="/stream.ogg" export FALLBACK_MOUNTPOINT="/greeting.ogg" export AUDIO_FILE="/path/to/waiting_music.ogg" export ADMIN_USERNAME="admin" export ADMIN_PASSWORD="@dmin-P4SSW0RD"
Create or open an ardour session to route, control and mix physical inputs as well as pre-recorded tracks, if any. Setup your session: Level gains, pan tracks and apply effects as you wish, but keep in mind to save some resources for encoding. If a recording is desired, it's enabled in transport bar and tracks are armed, too.
The actual source streaming happens when ardour's output is encoded by ffmpeg and piped to oggfwd, which sends the stream to Icecast for distribution to listeners.
The output of ardour must be encoded to Ogg Vorbis container format and provided at stdout to be forwarded by oggfwd. This can be achieved by using ffmpeg's JACK input device as well as audio encoding parameters and piping to oggfwd using the |
operator:
ffmpeg -f jack -i ffmpeg -vn -acodec libvorbis -b:a 192k -minrate 192k -maxrate 192k \ -metadata title="$CONCERT_TITLE" -metadata artist="$ARTIST_NAME" -f ogg -y /dev/stdout | oggfwd $HOSTNAME $PORT $SOURCE_PASSWORD $STREAM_MOUNTPOINT
ffmpeg parameters:
-f jack -i ffmpeg
: Create a JACK input device called ffmpeg.-vn
: Specify that no video data is included, streaming audio only.-acodec libvorbis
: Set audio codec to Vorbis by using libvorbis library.-b:a 192k -minrate 192k -maxrate 192k
: Ensure constant bitrate at 192 kbps for encoding.-metadata title="$CONCERT_TITLE" -metadata artist="$ARTIST_NAME"
: Add stream metadata.-f ogg -y /dev/stdout
: Force Ogg Vorbis output format and write to stdout location in Filesystem Hierarchy.
Use another terminal to connect ardour's master outputs to ffmpeg:input_1
and ffmpeg:input_2
within JACK:
jack_connect "ardour:Master/audio_out 1" ffmpeg:input_1 jack_connect "ardour:Master/audio_out 2" ffmpeg:input_2
When setting up those things all by yourself, it might be necessary play waiting music immediately after the source streaming started to save time. I'm using mpv with JACK audio output driver, auto-connecting to ffmpeg and looping the file $AUDIO_FILE in another terminal:
mpv --ao=jack --jack-port=ffmpeg --loop-file=inf $AUDIO_FILE
Press the m
key when starting the concert to mute mpv's output and press Play button in ardour's transport bar to start recording, if any.
Icecast's Admin Interface offers some functions to control listeners. I'm using wget to trigger those tasks at the terminal. General syntax is:
wget --quiet --output-document=/dev/null --http-user=$ADMIN_USERNAME \ --http-password=$ADMIN_PASSWORD https://$HOSTNAME:$PORT/admin/$WGET_URI
wget parameters:
--http-user=$ADMIN_USERNAME
: Use $ADMIN_USERNAME for Icecast web administration login--http-password=$ADMIN_PASSWORD
: Use $ADMIN_PASSWORD for Icecast web administration login--quiet
: Turn off terminal output.--output-document=/dev/null
: Write output document /dev/null, discard the download.
The value of $WGET_URI
depends on specific task.
The fallback mountpoint is activated since Icecast is running and listeners might have connected before the actual source stream started. To move listeners from one mountpoint to another, execute:
export WGET_URI="moveclients.xsl?mount=$FALLBACK_MOUNTPOINT&destination=$STREAM_MOUNTPOINT" wget --quiet --output-document=/dev/null --http-user=$ADMIN_USERNAME \ --http-password=$ADMIN_PASSWORD https://$HOSTNAME:$PORT/admin/$WGET_URI
It's useful to kill fallback streaming for misbehaving listener clients afterwards:
export WGET_URI="killsource.xsl?mount=$FALLBACK_MOUNTPOINT" wget --quiet --output-document=/dev/null --http-user=$ADMIN_USERNAME \ --http-password=$ADMIN_PASSWORD https://$HOSTNAME:$PORT/admin/$WGET_URI
At first mpv's output is unmuted by pressing m
to indicate the end of the concert. Then listener's will be moved back to fallback mount and source streaming is killed:
export WGET_URI="moveclients.xsl?mount=$STREAM_MOINTPOINT&destination=$FALLBACK_MOUNTPOINT" wget --quiet --output-document=/dev/null --http-user=$ADMIN_USERNAME \ --http-password=$ADMIN_PASSWORD https://$HOSTNAME:$PORT/admin/$WGET_URI export WGET_URI="killsource.xsl?mount=$STREAM_MOUNTPOINT" wget --quiet --output-document=/dev/null --http-user=$ADMIN_USERNAME \ --http-password=$ADMIN_PASSWORD https://$HOSTNAME:$PORT/admin/$WGET_URI
Lastly ffmpeg, oggfwd and mpv processes are killed:
killall -9 ffmpeg oggfwd mpv
In ardour, recording is stopped and the session is saved for later production.
Category: FLOSS media studio