[Flac-dev] OggFLAC streaming is systemically broken.

David Richards rawdod at gmail.com
Wed Dec 1 01:28:47 PST 2010


Not that many people are streaming FLAC, and if they are, they are, in
my mind, undoubtedly experiencing problems. Probably the most prized
kind of software problem of all, the intermittent kind.

I am streaming FLAC. 24bit no less, and its fantastic. The future I
would like to live in, is one where lossless music is streamed and
heard by people other than myself.

It is generally not possible to stream flac correctly with the current
libflac 1.2.1, unless your into epic kludges. There is at-least one
issue in libflac, and issues in decoding clients such as VLC, mplayer
and totem.

The good news is that one can hackfix libflac on the server side and
produce a valid stream that VLC and mplayer can take in without issue.
Totem seems to have other issues I have not investigated.

There seems to be two problems conspiring together. Both have to do
with silence. Even though what we really want to do is listen to music
or someone yapping, silence manages to be very important, be it a few
second in a song or long periods of dead air. Problem number one that
when libflac is pumping out silent subframes, the ogg pages are never
getting flushed out, because they are so small. So until there is some
noise or the page is full, the client decoder is left hanging. Then
when it starts decoding again, its decoding silence, and thus falls
far behind in the stream, probably confusing itself and disconnecting.
Problem number two, is even if you flush these little guys.. the
clients still get confused, especially if there is more than one per
page.

The epic kludge solution is to just never let there be any perfect
silence, not even for a few ms, plug in an old am radio and crank it
to just barely audible and add that to the stream.

The hackfix, is to disable constant subframes, and flush any packet
less than say 700 bytes, otherwise use pageout as normal.

The sustainable solution would probably be to add an option to libflac
to force flush the stream after X number of samples, and then fix all
of the clients. Then live the dream of streaming lossless audio.

Here is my hackfix:

https://github.com/oneman/libflac/commit/67e13364032404ebc1837af143fdd1cd81786c3a

I hope you like it.

Cheers,

David Richards


More information about the Flac-dev mailing list