2

I have a simple streamer developed in C++ using LibFlac and LibShout to stream to Icecast server. The flac Encoder is created in the following way:

  m_encoder = FLAC__stream_encoder_new();
  FLAC__stream_encoder_set_channels(m_encoder, 2);
  FLAC__stream_encoder_set_ogg_serial_number(m_encoder, rand());
  FLAC__stream_encoder_set_bits_per_sample(m_encoder, 16);
  FLAC__stream_encoder_set_sample_rate(m_encoder, in_samplerate);
  FLAC__stream_encoder_init_ogg_stream(m_encoder, NULL, writeByteArray, NULL, NULL, NULL, this);

The function writeByteArray sends encoded data to Icecast using shout_send_raw function from libshout. shout_send_raw returns an actual number of bytes being sent, so I assume that it works as it should, no error is happening. The problem is Icecast server does not stream the data that I send. I see followint in the log: [2018-02-15 15:31:47] DBUG stats/modify_node_event update "/radio" total_bytes_read (20735897) [2018-02-15 15:31:47] DBUG stats/modify_node_event update "/radio" total_bytes_sent (0) I see that Icecast receives the data, but it does not send it to connected clients. The mount point is radio and when I try to connect to that mount using any media player - it does nothing, no playback. So my question is how is that possible that Icecast receives the data but does not send it to connected clients? Maybe some additional libshout configuration is required, here is how I configure it: shout_set_format( m_ShoutData, SHOUT_FORMAT_OGG_AUDIO ); shout_set_mime( m_ShoutData, "application/ogg" ); Any help would be appreciated.

Alex Paramonov
  • 2,630
  • 2
  • 23
  • 27
  • 1
    FLAC is higher bitrate than the usual streams, did you increase the queue length for that mountpoint or global? There are several fault conditions where Icecast won't send data to clients. Not receiving proper headers is one, the other is not being able to fit a whole logic chunk of data in the queue. – TBR Feb 18 '18 at 09:48
  • Do you mean the `` config parameter? Tried to set `102400`, it did not help. – Alex Paramonov Feb 18 '18 at 15:30
  • Try a larger value. Don't forget to restart the Icecast server after changing the configuration. – TBR Feb 18 '18 at 20:31
  • I had to play with that parameter more and now it works good, thank you! – Alex Paramonov Feb 19 '18 at 09:42

1 Answers1

2

To sum up the solution from the comments:

FLAC has a very significantly higher bitrate than any other commonly used audio codec. Thus the default settings will NOT work. The queue size must be increased significantly so that complete data frames will fit in it, otherwise, Icecast will not sync on the stream and refuse to data out to clients.

The same obviously applies to streaming video. The queue size must be adjusted either for the appropriate mountpoints or globally.

TBR
  • 2,790
  • 1
  • 12
  • 22