ezstream - Man Page

source client for Icecast with external de-/encoder support

Synopsis

ezstream[-hqrVv] -c configfile [-p pidfile]
ezstream-s file

Description

ezstream is a command line source client for media streams, primarily for streaming to Icecast servers.

It allows the creation of media streams based on input from files or standard input that is piped through an optional external de- and encoder. As every part of this chain is highly configurable, ezstream can be useful in a large number of streaming setups.

Command line arguments

-c configfile

Use the XML configuration in configfile.

-h

Print a summary of available command line arguments with short descriptions and exit.

-p pidfile

Write the ezstream process ID (a single number) to pidfile. The file will be written even when it already exists. A file lock is maintained until the main ezstream process terminates. If the file cannot be written for any reason, ezstream will log this, but not consider it a fatal error.

-q

Be more quiet. Suppress the output that external programs send to standard error.

-r

Maintain a line of real-time status information about the stream on standard output. (Implies -q.)

-s file

Run ezstream as a line-based shuffling utility. If a playlist argument of “-” is given, a list of media file names is read from standard input instead of an input file. After successfully reading the entire list, it is shuffled and printed to standard output, and ezstream will exit.

-V

Print the ezstream version number and exit.

-v

Increase logging verbosity. May be used up to three times to also include debug logging output.

Runtime control

Ezstream offers limited runtime control via signals. By sending a signal to the ezstream process, e.g. with the kill(1) utility, a certain action will be triggered.

SIGHUP

Rereads the playlist file after the track that is currently streamed. If the playlist is not to be shuffled, ezstream attempts to find the previously streamed file and continue with the one following it, or restarts from the beginning of the list otherwise.

SIGUSR1

Skips the currently playing track and moves on to the next in playlist mode, or restarts the current track when streaming a single file.

SIGUSR2

Triggers rereading of metadata for the stream by running the configured program or script. This is the only meaningful signal when streaming from standard input.

Configuration File Syntax

The ezstream utility uses a simple XML configuration file format. It has a tree-like structure and is made up of XML elements. Of all the possible XML features, only regular elements that contain text or other elements, and comments, appear in an ezstream configuration file.

Each element in the configuration file consists of a start tag, its content, and an end tag. For example:

<filename>playlist.m3u</filename>

<!-- XML comments look like this. -->

XML Configuration

In this section, each available element is listed and described. Note that for this purpose, elements are introduced in their short, i.e. empty form. In the configuration file, they need to be used as start tag + content + end tag, like in the introductory example shown above.

Root element

<ezstream />

(Mandatory.) The configuration file's root element. It contains all other configuration elements.

Servers block

<servers />

This element contains all server blocks as child elements. Its parent is the <ezstream /> element.

A configuration file may contain multiple named server configurations. The stream configuration determines what server configuration should be used.

Server block

<server />

(Mandatory.) This element contains a complete server configuration as child elements. Its parent is the <servers /> element.

Server configuration

<name />

Set the name of the server configuration. This may be referenced in a <stream />.

The name is case-aware, but not case-sensitive.

Default: default

<protocol />

Transport protocol used to stream to the server:

HTTP

Plain-text HTTP. The <tls /> option defines, if TLS via RFC2817 or RFC2818 is also attempted.

HTTPS

HTTP over TLS. This option implies that <tls /> is set to "required".

ICY

ICY streaming protocol

RoarAudio

RoarAudio streaming protocol

Default: HTTP

<hostname />

(Mandatory.) The FQDN host name or IP address of the server.

<port />

Port number on which the server is listening.

Default: 8000

<user />

User to authenticate as on the server.

Default: source

<password />

(Mandatory.) Password to authenticate with on the server.

<reconnect_attempts />

Number of reconnect attempts in case of connection issues with the server, or 0 (zero) for trying indefinitely.

Default: 0

<tls />

Configure the TLS encryption requirement for the server connection. Possible values are:

None

No TLS encryption will be attempted.

May

Opportunistic TLS encryption may be used, if the server supports it

Required

TLS encryption is required. This is the only setting that is providing security against both passive and active attackers.

Default: May

This option is ignored when <protocol /> is set to HTTPS, which implies a value of Required.

<tls_cipher_suite />

Configure allowed cipher suites for TLS.

For example (modern cipher suites, PFS, TLS 1.2 or better): HIGH:!RSA:!SHA:!DH:!aNULL:!eNULL:!TLSv1.

Default: libshout default cipher suite

<ca_dir />

Directory in which OpenSSL finds root CA certificates for validating the HTTPS server identity.

Default: system default

<ca_file />

Path of a root CA bundle file for validating the HTTPS server identity.

Default: system default

<client_cert />

X.503 client certificate and key (in PEM format containing both certificate and key in the same file) for authentication on an HTTPS server.

Default: no client certificate authentication

Streams block

<streams />

This element contains all stream blocks as child elements. Its parent is the <ezstream /> element.

Note: While multiple stream configurations are supported by the file format, only the one configuration with the name default will be used by ezstream.

Stream block

<stream />

(Mandatory.) This element contains the entire stream configuration as child elements. Its parent is the <streams /> element.

Stream configuration

<name />

Set the name of the stream configuration.

The name is case-aware, but not case-sensitive.

Note: At this time, only the stream configuration with the default name is used and must be present.

Default: default

<mountpoint />

(Mandatory.) Stream mountpoint on the server.

<public />

Boolean setting of whether the broadcast may be listed in a public YP directory, or not.

0|No|False

The broadcast is private (the default).

1|Yes|True

The broadcast is public.

<intake />

Use the intake (input media) configuration with the provided symbolic name for this stream.

Default: default

<server />

Use the server configuration with the provided symbolic name for this stream.

Default: default

<format />

(Mandatory.) The stream format.

Ogg

Ogg media format

MP3

MP3 audio format

WebM

WebM media format

Matroska

Matroska media format

<encoder />

Use the encoder configuration with the provided symbolic name (see below), for (re)encoding the stream. Not configuring an encoder makes ezstream stream input media files as-is.

The configured encoder's output stream format must match what is configured in <format />.

<stream_name />

Informational name of the broadcast.

Default: none

<stream_url />

Informational URL associated with the broadcast, e.g. the web site.

Default: none

<stream_genre />

Informational genre of the broadcast.

Default: none

<stream_description />

Informational description of the broadcast.

Default: none

<stream_quality />

Informational quality setting of the VBR broadcast.

Default: none

<stream_bitrate />

Informational bitrate setting of the CBR broadcast.

Default: none

<stream_samplerate />

Informational sample rate of the broadcast audio.

Default: none

<stream_channels />

Informational number of audio channels of the broadcast.

Default: none

Intakes block

<intakes />

This element contains all intake blocks as child elements. Its parent is the <ezstream /> element.

A configuration file may contain multiple named intake configurations. The stream configuration determines what intake (media input) configuration should be used.

Intake block

<intake />

(Mandatory.) This element contains the entire input media configuration as child elements. Its parent is the <intakes /> element.

Intake configuration

<name />

Set the name of the intake configuration. This may be referenced in a <stream />.

The name is case-aware, but not case-sensitive.

Default: default

<type />

Configure the input media type:

autodetect

Attempt to autodetect, whether the input is a playlist, or a single media file. Playlists are detected by their “.m3u” and “.txt” file name extensions. (This is the default.)

file

The input is one single media file.

playlist

The input is a playlist. Playlists are a newline-delimited list of media file path names. Comments in playlists are introduced by a ‘#’ sign at the beginning of a line and ignored by ezstream.

program

The input is an executable “Playlist Program”. See Scripting for more information.

stdin

The input is read from standard input and streamed as-is without any reencoding.

<filename />

The input media file name; mandatory for all but the stdin type.

<shuffle />

Boolean setting of whether the playlist type media should be shuffled, or not.

0|No|False

Stream the playlist content sequentially (the default).

1|Yes|True

Shuffle the playlist prior to streaming its content.

<stream_once />

Boolean setting of whether ezstream should exit after streaming its media input, or start over.

0|No|False

Attempt to start over whenever the end of the media input is reached (the default).

1|Yes|True

After streaming all media input, exit.

Metadata block

<metadata />

This element contains the entire metadata configuration as child elements. Its parent is the <ezstream /> element.

Metadata configuration

<program />

Set an executable “Metadata Program” to be queried for all metadata on SIGUSR2 or whenever a new track begins. See Scripting for more information.

Default: use metadata as contained in media files

<format_str />

Set the format of the string that should be used for the ‘@M@’ placeholder, when quering for metadata from an executable.

Default: @a@ - @t@

<refresh_interval />

Configure a time interval for additional metadata updates via a “Metadata Program”:

-1

Do not trigger any additional metadata updates (the default).

0

Trigger metadata updates at the highest reasonable frequency.

>0

Configure the time (in seconds) in between additional metadata updates.

<normalize_strings />

Boolean setting of whether metadata strings should have excess whitespace removed, or not.

0|No|False

Use metadata strings as-is (the default).

1|Yes|True

Trim leading and trailing whitespace, as well as remove excess whitespace in case that there is more than one in sequence.

<no_updates />

Boolean setting of whether metadata updates should be suppressed altogether, or not.

0|No|False

Update metadata in the usual manner (the default).

1|Yes|True

Disable all metadata updates, and keep existing metadata in streams untouched.

Decoders block

<decoders />

This element contains all decoder blocks as child elements. Its parent is the <ezstream /> element.

Decoder block

<decoder />

This element contains all configuration of a single decoder. Its parent is the <decoders /> element.

Decoder configuration

<name />

Set the name of the decoder configuration.

The name is case-aware, but not case-sensitive.

Default: default

<program />

(Mandatory.) Set the full command line to decode a media input file, represented by the ‘@T@’ placeholder, into a “canonical internal format” on standard output.

The canonical format should be the same for all configured decoders, e.g. RAW audio with a specific signedness, bitrate, and samplerate that can be consumed by encoders.

For exotic use cases, metadata placeholders may be used here.

Example:

<program>oggdec -R -o - @T@</program>

<file_ext />

(Mandatory.) Set a filename extension to be associated with this decoder.

It is possible to specify more than one <file_ext /> element per decoder to associate more than one file extension to the same decoder.

A filename extension can only be associated with one decoder.

Encoders block

<encoders />

This element contains all encoder blocks as child elements. Its parent is the <ezstream /> element.

Encoder block

<encoder />

This element contains all configuration of a single encoder. Its parent is the <encoders /> element.

Encoder configuration

<name />

(Mandatory.) Set the name of the encoder configuration. This may be referenced in a <stream /> block in case (re)encoding is desired.

The name is case-aware, but not case-sensitive.

Default: default

<format />

(Mandatory.) Stream format produced by this encoder. This must be one of the available stream formats as specified for the <stream /> block.

<program />

(Mandatory.) Set the full command line to encode the “canonical internal format” from standard input into a supported stream format on standard output.

Metadata placeholders may be used here.

Example:

<program>oggenc -r -q 1.5 -t @M@ -</program>

Scripting

The ezstream utility provides hooks for externally controlled playlist and metadata management. This is done by running external programs or scripts that need to behave in ways explained here.

Common Rules

  • The program must be an executable file.

  • The program must write one line to standard output and exit.

  • The program must not require arbitrary command line options to function. A wrapper script must be used if there is no other way.

Playlist Programs

  • The program must return only filenames, with one filename per execution.

  • The program should not return an empty line unless ezstream is supposed to know that the end of the playlist has been reached. This is significant when the <stream_once/> option is enabled.

Metadata Programs

  • The program must not return anything (just a newline character is okay) if it is called by ezstream with a command line argument that the program does not support.

  • When called without command line arguments, the program should return a complete string that should be used for metadata.

  • When called with the command line argument "artist", the program should return only the artist information of the metadata. (Optional.)

  • When called with the command line argument "title", the program should return only the title information of the metadata. (Optional.)

  • The supplied metadata must be encoded in UTF-8.

Metadata

The main tool for handling metadata with ezstream is placeholders in decoder and encoder commands that are replaced with real content during runtime.

Note: All placeholders are replaced with content enclosed in single quotes, with escaped single quote and backslash characters in between, so that interpretation by the shell does not occur. Do not add any additional quoting!

Metadata Placeholders

@T@

Replaced with the media file name. Required in /ezstream/decoders/decoder/program. Available in /ezstream/metadata/format_str.

@M@

Replaced with a metadata string. (See below for a detailed explanation.) Available in /ezstream/decoders/decoder/program and /ezstream/encoders/encoder/program.

@a@

Replaced with the artist information. Available in /ezstream/decoders/decoder/program, /ezstream/encoders/encoder/program and /ezstream/metadata/format_str.

@t@

Replaced with the title information. Available in /ezstream/decoders/decoder/program, /ezstream/encoders/encoder/program and /ezstream/metadata/format_str.

@b@

Replaced with the album information. Available in /ezstream/decoders/decoder/program, /ezstream/encoders/encoder/program and /ezstream/metadata/format_str.

@s@

Replaced with the string returned by /ezstream/metadata/program when called without any command line arguments. Available only in /ezstream/metadata/format_str.

The @M@ Placeholder

While all other placeholders are simply replaced with whatever data they are associated with, ‘@M@’ is context-sensitive. The logic used by ezstream is the following:

If ('@M@ is present')
    If (/ezstream/metadata/program AND /ezstream/metadata/format_str)
        Replace with format string result.
    Else
        If (NOT /ezstream/metadata/program AND '@t@ is present')
            Replace with empty string.
        else
            Replace with generated metadata string.
        Endif
    Endif
Endif

The generated metadata string for ‘@M@’ is of the format “Artist - Title”, if both artist and title information is available. If one of the two is missing, the available one is displayed without a leading or trailing dash, e.g. just “Artist”. If neither artist nor title are available, the name of the media file — without its file extension — is used.

Metadata Caveats

It is possible to generate strange results with odd combinations of placeholders, external metadata programs and updates during runtime via SIGUSR2. If things start to become just confusing, simplify.

Metadata updates during runtime are done with a eccentric feature of libshout. Additional metadata information that is already present in the stream sent via ezstream is usually destroyed and replaced with the new data. It is not possible to properly discern between artist and title information, which means that anything set with the SIGUSR2 feature will continue to end up entirely in the "Title" field of a stream.

Additional limitations in Icecast may apply as well, where one historic example is that of all possible Ogg-based streams, only Ogg Vorbis can have its metadata manipulated.

The ID3v1 tags (relevant when streaming in MP3 format) do not specify any character encoding, so ezstream operates in a manner of “best effort”. In case of encoding issues, it may help to explicitly set a codeset to work with via the LC_CTYPE environment variable, as ezstream assumes ID3v1 tags to be in the user's current locale. Note that, even though support for different locales is provided by ezstream, Icecast itself and the listening clients also have a say in the matter. The only way to ensure consistent results with metadata in non-Ogg streams is to use only the characters available in the ISO-8859-1 codeset.

External encoders may put additional, and possibly artificial, restrictions on valid characters in metadata.

Files

/usr/share/examples/ezstream

Directory containing example configuration files for various uses of ezstream, as well as example playlist and metadata scripts.

See Also

ezstream-cfgmigrate(1), ezstream-file.sh(1)

Authors

ezstream was written by:

Ed Zaleski ⟨oddsock@oddsock.org⟩
Moritz Grimm ⟨mgrimm@mrsserver.net⟩

This manual was written by Moritz Grimm.

Referenced By

ezstream-cfgmigrate(1), ezstream-file.sh(1).

January 24, 2024