Sonos Music API - Getting Started Guide

FLAC Best Practices

FLAC stands for Free Lossless Audio Codec. The codec and its reference libraries operate under the Berkeley Source Distribution (BSD) license, making it an excellent choice for lossless compression of tracks. FLAC source code and documentation can be found on its website.

Follow these best practices for encoding FLAC files when sending them to Sonos players.

Include a seek table in file metadata

A seek table helps reduce the number of calls Sonos players make to the track host. We recommend a seek table with 1% resolution (100 entries) as this resolution halves the number of seek requests needed to stream FLAC. On a 6-minute stereo track with a blocksize of 4096, players make 1-2 requests with a seek table and 2-4 without. On a 25-minute track with identical parameters, players make 2-3 requests with a seek table, and 4-6 without.

Include maximum & minimum frame sizes in streaminfo

You can improve seeking by including the minimum and maximum frame sizes. This size information allows the decoder to determine an average size per frame. See the FLAC documentation on streaminfo for details.

Use a bit-depth of 16

While FLAC does support bit-depths from 4 bits to 32 bits, we only support 16-bit FLAC. 

Use at most 2 channels

We currently support only mono and stereo FLAC encodings, with the first channel being the left, and the second channel being the right. Follow the FLAC frame header specifications to determine which channel is which side.

Use 44.1 kHz or 48 kHz sample rate

Sonos supports 16, 22.05, 24, 32, 44.1, and 48 kHz audio. We do not support anything higher, such as 96 kHz. For quality reasons, we do not suggest using encoding tracks in anything less than 44.1 kHz.

Use up to a 32 KB maximum frame size

After evaluating our music partners who supply 24-bit we have determined that frame sizes are usually around 3-6 KB or 13-17 KB. With this in mind we decided on a 32 KB max frame size to work effectively across all Sonos products. To achieve this maximum Frame Size when encoding, use a blocksize such that:

([blocksize] * [bit_depth] * [number_of_channels]) / 8 <= 32 KB

This will guarantee that after compression the frame size will be below the 32 KB maximum.