The latest development (read: unstable) version of TVHeadend merged a new feature from fellow developer Hyper which allows TVHeadend to extract (and transcode) the audio stream of any source that is configured in TVHeadend (e.g. a DVB-S or DVB-T stream). This is an exciting feature as it allows you to set up “stations” on devices such as Sonos and play the audio directly from TVHeadend on the Sonos device(s) – this also applies to other audio platforms such as Squeezebox etc.
First up, lets create a streaming profile to pass only an audio stream to the receiving device.
Navigate to Configuration > Stream Profiles > Add and select “Transcode/av-lib” as the type
Next, configure the stream profile as per the screenshot below, only the following settings need amending, leave everything else as per the defaults;
Enabled: True Profile Name: Audio (or whatever you like) Container: Raw Audio Stream Video Codec: Do not use Audio Codec: AAC or Vorbis Audio Bitrate: 128 (or whatever you like)
Click “Create” to finish setting up the profile.
Next, we need to configure a user that will be used to identify the client(s) (i.e. the Sonos receivers) to TVHeadend so that TVHeadend sends the stream in the correct format to the receiver.
Navigate to Configuration > Users > Access Entries and click “Add”
Next, configure the user as per the screenshot below, only the following settings need amending, leave everything else as per the defaults;
Enabled: True Username: * Streaming: True Advanced Streaming: True Allowed Networks: 192.168.1.71/32,192.168.1.72/32,192.168.1.77/32 Streaming Profiles: audio (or whatever you called your new profile above)
Setting the username to asterisk (*) means any or no user, we then limit who (or what) can access the user profile by setting the appropriate network settings. In my example above, I allow my 3 Sonos devices (192.168.1.71, 192.168.1.72 and 192.168.1.77) to access TVHeadend. The /32 at the end of the address simply means “only this IP address” in CIDR network notation. Amend the network settings to suite your environment.
The last part is client-specific, so the example below is relevant only to Sonos, but the principle will be the same regardless of which client you are using.
First, grab the URL of the channel you want to add as a stream in your client. Navigate to Configuration > Channel / EPG > Channels, find the channel you want to stream, right click on the icon and copy the URL to the clipboard. The URL will look similar to the below;
We need to remove the parameter at the end of the URL (the bit from the question mark onwards) to give us
You now have your streaming URL. Next, go to your client (in my case Sonos), find the option for adding a stream (or radio station) and paste the URL into the dialog box.
That’s it – if you try and play the stream, your client should connect to TVHeadend and start streaming only the audio element of the stream. You can check that your client is connected to TVHeadend and using the right stream by navigating to Status > Subscriptions and checking for a client using your “Audio” profile (or whatever you named it in the first step above)