glasscoder — Minimalist audio encoder for live streaming
glasscoder(1) is an audio encoder that is capable of generating live streams using a variety of formats and sending them to an Icecast or Shoutcast audio streaming server or posting them as HTTP Live Streams [HLS]. It is also capable of acting as an Icecast-compatible server in its own right, serving streams directly to client players and thus eliminating the need for an intervening Icecast server instance.
glasscoder(1) has no GUI or configuration file components at all; its sole 'user interface' being its command-line invocation. As such, it is particularly well suited for being driven by an external process or controller such as glassgui(1) or glasscommander(1).
--audio-atomic-frames
Emit a stream consisting of self-contained frames --e.g. by disabling the MPEG-1 bit reservoir. Useful mostly for debugging.
--audio-bitrate=
kbps
The constant stream data rate in kilobits per second. Default value
is 128
. Use of this option is mutually
exclusive with that of the --audio-quality
option
(see below).
--audio-channels=
chans
The number of audio channels to use. Valid values are
1
or 2
.
Default value is 2
.
--audio-device=
type
The type of audio device to use. The default value is
JACK
. See the
DEVICE OPTIONS section (below) for
the options appropriate for each audio device type. Valid values
are:
ALSA
The Advanced Linux Sound Architecture.
ASIHPI
AudioScience HPI.
FILE
Stream directly from a file.
JACK
The Jack Audio Connection Kit.
--audio-format=
fmt
The audio encoding format to use. The default value is
VORBIS
. Valid fmt
values are:
AACP
MPEG-4 Advanced Audio Coding "Plus" (High Efficiency Profile)
MP2
MPEG-1/1.5 Layer 2
MP3
MPEG-1/1.5 Layer 3
OPUS
Ogg Opus (RFC-6716)
PCM16
PCM16 Uncompressed
VORBIS
Ogg Vorbis
--audio-quality=
qual
Use variable bitrate streaming at the given audio quality.
qual
can be in the range
0.0
(lowest quality) to
1.0
(highest). Use of this option is mutually
exclusive with that of the --audio-bitrate
option
(see above).
--audio-samplerate=
rate
The audio sample rate to use for streaming. If the underlying
audio layer is operating at a different sample rate, the input will
be automatically resampled to this rate.
Default value is 44100
.
--errors-string=
string
Prepend string
to messages sent to the
syslog service (see the
--errors-to
option, below). Useful for
disambiguating messages from multiple
glasscoder(1) instances.
--errors-to=
dest
Send error messages to dest
(default
standard error). Valid destinations are:
STDERR
Standard error.
SYSLOG
The system syslog service.
STDOUT
Standard output,in machine readable format (useful for communication with another 'controller' program). See also the
--meter-data
option below.
--help
Print a short usage message and exit.
--list-codecs
Print a list of available codecs and then exit.
--list-devices
Print a list of available source devices and then exit.
--metadata-port=
port
Accept metadata updates via HTTP at port
port
. Default value is
0
, which disables metadata updates.
See the METADATA section (below) for information regarding the
supported update formats.
--meter-data
Output meter level updates on standard output. Useful for driving an external metering display.
--server-auth=
[username
][:
password
]
The authentication parameters to use. This parameter has no default.
--server-exit-on-last
Exit the program upon closure of the last player connection. This setting is used only by the IceStreamer server.
--server-max-connections=
conns
Allow a maximum of conns
simultaneous
player connections. Players beyond this maximum attempting to
connect will receive an immediate TCP disconnect before the HTTP
handshake. This setting is used only by the IceStreamer server.
--server-pipe=
pathname
Location to create a UNIX socket for piping connection socket descriptors. Useful for implementing proxy connectors for the IceStreamer server. For further details about this feature, see the Proxy Connections section of the glasscoder-ipc(7) man page. The default is to create no UNIX socket. This setting is used only by the IceStreamer server.
--server-script-down=
cmd
Run the command cmd
when the connection
enters the
disconnected
state.
--server-script-up=
cmd
Run the command cmd
when the connection
enters the connected
state.
--server-start-connections=
conns
Do not start the audio transport until at least
conns
connections have been established.
Used only by the IceStreamer server in conjunction with the
FILE
audio device. Default value is
0
--i.e. start the transport immediately.
--server-type=
type
The type of streaming server to use (default is
Icecast2
). Valid values for
type
are:
FILE
Local file
FILEARCHIVE
Local file archive. Stream to a set of files on the local system, starting a new file at the beginning of each hour.
HLS
HLS/HTTP Live Streaming
IceCast2
IceCast v2
IceOut
Output an Icecast-compatible stream on standard output.
IceStreamer
Stream directly to players using the internal Icecast-compatible server.
Shout1
Shoutcast v1
Shout2
Shoutcast v2
--server-url=
url
The URL describing the server resource to stream to. See the SUPPORTED URL SCHEMES section (below) for a list of what URL schemes are appropriate for which server types.
When used with a --server-type
of
IceStreamer
, the host part of the URL
is used to specify the address of the network interface to
use for streaming (use 0.0.0.0
to indicate
ALL interfaces). This parameter has no default.
--server-user-agent=
agent-string
The User-Agent
header value to
use when connecting to external servers. Default value is
GlassCoder/1.0.0
. This setting
is used only by IceCast2
and
HLS
servers.
--stream-aim=
aim
The AOL Instant Messenger ID to associate with the stream. There is no default value. This setting is used only by Shoutcast servers.
--stream-description=
string
The string to show as the stream description. There is no default value. This setting is used only by Icecast servers.
--stream-genre=
string
The string to show as the stream genre. There is no default value. This setting is used only by Icecast and Shoutcast servers.
--stream-icq=
icq
The ICQ ID to associate with the stream. There is no default value. This setting is used only by Shoutcast servers.
--stream-irc=
irc
The Internet Relay Chat ID to associate with the stream. There is no default value. This setting is used only by Shoutcast servers.
--stream-name=
string
The string to show as the stream name. There is no default value. This setting is used only by Icecast and Shoutcast servers.
--stream-timestamp-offset=
offset
The offset to add to the value of stream timestamps, in seconds.
Default value is 0
. This setting is used
only for HLS streams.
--stream-url=
url
The URL to show for a page giving more information about the stream. There is no default value. This setting is used only by Icecast and Shoutcast servers, but is ignored by Shoutcast v2 servers.
--verbose
Increase verbosity level of information printed to standard error. WARNING: this may cause cleartext passwords to printed!
--version
Output version information and exit.
--audio-device=
ALSA
)
--alsa-device=
dev
The name of the ALSA device to use. If no
--audio-device
option is given,
then the hw:0
device will be used.
--audio-device=
=ASIHPI
)
--asihpi-adapter-index=
index
The index number of the audio adapter to use.
--asihpi-input-index=
index
The number of the input audio stream to use on the specified adapter.
--asihpi-input-gain=
gain
The gain to apply to the input audio on the specified adapter in
dB. Valid values are -100
to
+20
inclusive. Default value is
0
.
--asihpi-channel_mode=
mode
The channel mode for the input audio on the specified adapter.
The default value is NORMAL
. Valid values
are:
NORMAL
Left signal goes to left channel, right signal goes to right channel.
SWAP
Left signal goes to right channel, right signal goes to left channel.
LEFT
Left signal goes to both left and right channels.
RIGHT
Right signal goes to both left and right channels.
--asihpi-input-source=
src-node
The input source to use on the specified adapter. See the
HPI Source Nodes section below
for the list of valid src-node
values. The default value is LINEIN
.
--asihpi-input-type=
src-node
The input type to use on the specified adapter. See the
HPI Source Nodes section below
for the list of valid src-node
values. The default value is LINEIN
.
The following values can used for the
--asihpi-input-source
and
--asihpi-input-type
options above:
NONE
,
OSTREAM
Internal output stream
LINEIN
Generic input signal
AESEBU
AES3 digital input
TUNER
Tuner
RF
RF input
CLOCK
Clock source
BITSTREAM
Raw bitstream
MIC
Microphone
COBRANET
CobraNet
ANALOG
Analog input
ADAPTER
Adapter
RTP
,
INTERNAL
Device internal
AVB
AVB input
--audio-device=
FILE
)
--file-name=
name
The name of the file to stream. If no
--file-name
option is given,
then the name of the file will be read from standard input.
--audio-device=
JACK
)
--jack-client-name=
name
The name of the JACK client to use. Default is
glasscoder
.
--jack-gain=
gain
Apply a fixed gain of gain
dB
before encoding. Default is 0
dB.
--jack-server-name=
name
The name of the JACK server instance to use.
Not all URL schemes are supported by all server types. The following chart breaks down the options.
Table 1. Supported URL Schemes by Server Type
Server Type | FILE:// | HTTP:// | SFTP:// |
---|---|---|---|
FILE | Yes | No | No |
FILEARCHIVE | Yes | No | No |
HLS | Yes | Yes [1] | Yes [3] |
IceCast2 | No | Yes [2] | No |
IceOut | No | Yes | No |
IceStreamer | No | Yes | No |
Shout1 | No | Yes [2] | No |
Shout2 | No | Yes [2] | No |
[1] Utilizes the HTTP PUT and DELETE methods | |||
[2] Utilizes the HTTP GET method | |||
[3] Supports ssh(1) password authentication only |
GlassCoder supports the notion of two types of metadata: "channel-based" metadata, which applies to the stream as a whole and does not change for the duration of an encoding session; and "timed" metadata, which can be changed in synchronization with the content of the audio stream. Channel-based metadata can be specified by means of options given to glasscoder(1) and will be covered in detail in the sections devoted to specific server types (below).
The primary mechanism for supplying timed metadata in GlassCoder is by
means of a JSON document containing the desired metadata, sent to the
target glasscoder(1) instance
at the port specified by the --metadata-port
option
by means of an HTTP POST operation. The basic format
of the JSON document is as follows:
{
"Metadata": {
"Field1": "Some value",
"Field2": "Some other value"
}
}
Not all server types support metadata, and those that do utilize wildly different schemas. Following is a breakdown of the available metadata options by server type:
IceCast2 supports the following channel metadata fields:
Specified by the --stream-name
option.
Specified by the
--stream-description
option.
Should be a link to content related to the stream. Specified by the
--stream-url
option.
Should be a single word describing the nature of the stream content.
Specified by the --stream-genre
option.
IceCast2 provides one field of text, called
StreamTitle
, which can be dynamically
updated to reflect the content currently playing on the stream.
By convention, this is usually formatted as
'Artist
- Title
' on streams
containing musical content.
For example, to set the StreamTitle
field to
The Beatles - Hey Jude
, the following JSON
could be used:
{
"Metadata": {
"StreamTitle": "The Beatles - Hey Jude"
}
}
In addition to the primary JSON interface, the
StreamTitle
can be set by sending an HTTP
GET request to a running
glasscoder(1) instance,
using the TCP port specified in the
--metadata-port=
port
option.
The request must be in the following format:
http://hostname
:tcp-port
/admin/metadata?mount=mount-point
&mode=updinfo&song=string
Where:
hostname
- The hostname or IP address of the
system running glasscoder(1)
tcp-port
- The TCP port number specified in the
--metadata-port
option to
glasscoder(1)
mount-point
- The mountpoint of the stream
string
- The string to set, encoded as specified
in Section 2 of RFC3986
For example, to set a string of "The Beatles - Hey Jude" via a
glasscoder(1) instance running at
encoder.example.com
with a
--metadata-port
value of 1234
for a mountpoint of MyStream
, the URL would be:
http://encoder.example.com:1234/admin/metadata?mount=MyStream&mode=updinfo&song=The%20Beatles%20-%20Hey%20Jude
ShoutCast supports the following channel metadata fields:
Specified by the --stream-name
option.
Should be a link to content related to the stream. Specified by the
--stream-url
option.
Should be a single word describing the nature of the stream content.
Specified by the --stream-genre
option.
Should be User Identification Number for an ICQ user associated with
the stream content. Specified by the --stream-icq
option.
Should be an ID for an AOL Instant Messenger user associated with the
stream content. Specified by the --stream-aim
option.
Should be an ID for an Internet Relay Chat channel associated with
the stream content. Specified by the --stream-irc
option.
ShoutCast provides two fields of text which can be dynamically updated to
reflect the content currently playing on the stream, called
StreamTitle
and
StreamUrl
. By convention, the
StreamTitle
is usually formatted as
'Artist
- Title
' on streams
containing musical content, while StreamUrl
is used to provide a URL whence stream specific content --e.g. album cover
art -- can be retrieved.
For example, to set the StreamTitle
field to
The Beatles - Hey Jude
and the
StreamUrl
field to
http://images.example.com/1234.png
, the following
JSON could be used:
{
"Metadata": {
"StreamTitle": "The Beatles - Hey Jude",
"StreamUrl": "http://images.example.com/1234.png"
}
}
In addition to the primary JSON interface, the
StreamTitle
and
StreamUrl
fields can be set by sending
an HTTP GET request to a running
glasscoder(1) instance,
using the TCP port specified in the
--metadata-port=
port
option.
The request must be in the following format:
http://hostname
:tcp-port
/admin.cgi?pass=password
&mode=updinfo&song=stream-title
&url=stream-url
Where:
hostname
- The hostname or IP address of the
system running glasscoder(1)
tcp-port
- The TCP port number specified in the
--metadata-port
option to
glasscoder(1)
password
- The ShoutCast password, encoded as
specified in Section 2 of RFC3986
stream-title
- The string to set for StreamTitle
, encoded as specified in Section 2 of RFC3986
stream-url
- The string to set for StreamUrl
, encoded as specified in Section 2 of RFC3986
For example, to set a StreamTitle
of
"The Beatles - Hey Jude" and a
StreamUrl
of
"http://image.example.com/1234.png" with a password of
"MyPassword" via a
glasscoder(1) instance running at
encoder.example.com
with a
--metadata-port
value of 1234
,
the URL would be:
http://encoder.example.com:1234/admin.cgi?pass=MyPassword&mode=updinfo&song=The%20Beatles%20-%20Hey%20Jude&url=http://image.example.com/1234.png
HLS supports timed metadata in the form of embedded ID3v2.4 tags. Available fields thus include the entire set of text tags defined in the ID3v2.4 frame specification (available at http://id3.org/id3v2.4.0-frames).
For example, a typical metadata update could use the following JSON:
{
"Metadata": {
"TIT2": "Hey Jude",
"TPE1": "The Beatles",
"TALB": "The White Album",
"TRSO": "WXYZ Radio"
}
}
A user defined text information frame (TXXX
) can
be sent by using the following special notation for the field identifier:
TXXXdesc
Where:
desc
- The TXXX Description string (see
Section 4.2.6 of the ID3v2.4 Frame Specification)
For example:
{
"Metadata": {
"TIT2": "Hey Jude",
"TPE1": "The Beatles",
"TALB": "The White Album",
"TRSO": "WXYZ Radio",
"TXXXxyz": "TXXX frame with a description string of \"xyz\""
}
}