LIVESTREAMER(1)

NAME
livestreamer - extracts streams from various services and pipes them into a video player of choice

TUTORIAL

Livestreamer is command-line application, this means the commands described here should be typed into a terminal. On Windows this means you should open the command prompt or PowerShell, on Mac OS X open the Terminal app and if you're on Linux or BSD you probably already know the drill.

The way Livestreamer works is that it's only a means to extract and transport the streams, and the playback is done by an external video player. Livestreamer works best with VLC or mpv, which are also cross-platform, but other players may be compatible too, see the Players page for a complete overview.

Now to get into actually using Livestreamer, let's say you want to watch the stream located on http://twitch.tv/day9tv, you start off by telling Livestreamer where to attempt to extract streams from. This is done by giving the URL to the command livestreamer as the first argument:

$ livestreamer twitch.tv/day9tv
[cli][info] Found matching plugin twitch for URL twitch.tv/day9tv
Available streams: audio, high, low, medium, mobile (worst), source (best)

NOTE: You don't need to include the protocol when dealing with HTTP URLs, e.g. just twitch.tv/day9tv is enough and quicker to type.

This command will tell Livestreamer to attempt to extract streams from the URL specified, and if it's successful, print out a list of available streams to choose from.

To select a stream and start playback, we simply add the stream name as a second argument to the livestreamer command:

$ livestreamer twitch.tv/day9tv source
[cli][info] Found matching plugin twitch for URL twitch.tv/day9tv
[cli][info] Opening stream: source (hls)
[cli][info] Starting player: vlc

The stream you chose should now be playing in the player. It's a common use case to just want start the highest quality stream and not be bothered with what it's named. To do this just specify best as the stream name and Livestreamer will attempt to rank the streams and open the one of highest quality. You can also specify worst to get the lowest quality.

Now that you have a basic grasp of how Livestreamer works, you may want to look into customizing it to your own needs, such as:

•   Creating a configuration file of options you want to use

•   Setting up your player to cache some data before playing the stream to help avoiding buffering issues

CONFIGURATION FILE

Writing the command-line options every time is inconvenient, that's why Livestreamer is capable of reading options from a configuration file instead.

Livestreamer will look for config files in different locations depending on your platform:
Platform | Location
Unix-like (POSIX) | $XDG_CONFIG_HOME/livestreamer/config ~/.livestreamerrc
Windows | %APPDATA%\livestreamer\livestreamerrc

You can also specify the location yourself using the --config option.

NOTE:

•   $XDG_CONFIG_HOME is ~/.config if it has not been overridden

•   %APPDATA% is usually <your user directory>\Application Data

    NOTE: On Windows there is a default config created by the installer but on any other platform you must create the file yourself.

  Syntax

The config file is a simple text file and should contain one command-line option (omitting the dashes) per line in the format:

option=value

or for a option without value:

option

NOTE: Any quotes used will be part of the value, so only use when the value needs them, e.g. specifiying a player with a path containing spaces.

  Example

# Player options
player=mpv --cache 2048
player-no-close
# Authenticate with Twitch
twitch-oauth-token=mytoken

PLUGIN SPECIFIC CONFIGURATION FILE

You may want to use specific options for some plugins only. This can be accomplished by placing those settings inside a plugin specific config file. Options inside these config files will override the main config file when a URL matching the plugin is used.

Livestreamer expects this config to be named like the main config but with .<plugin name> attached to the end.

  Examples
Platform | Location
Unix-like (POSIX) | $XDG_CONFIG_HOME/livestreamer/config.twitch ~/.livestreamerrc.ustreamtv
Windows | %APPDATA%\livestreamer\livestreamerrc.youtube

Have a look at the list of plugins to see the name of each built-in plugin.

PLUGIN SPECIFIC USAGE

  Authenticating with Twitch

It's possible to access subscription content on Twitch by giving Livestreamer access to your account.

Authentication is done by creating an OAuth token that Livestreamer will use to access your account. It's done like this:

$ livestreamer --twitch-oauth-authenticate

This will open a web browser where Twitch will ask you if you want to give Livestreamer permission to access your account, then forwards you to a page with further instructions on how to use it.

  Authenticating with Crunchyroll

Crunchyroll requires authenticating with a premium account to access some of their content. To do so, the plugin provides a couple of options to input your information, --crunchyroll-username and --crunchyroll-password.

You can login like this:

$ livestreamer --crunchyroll-username=xxxx --crunchyroll-password=xxx http://crunchyroll.com/a-crunchyroll-episode-link

NOTE: If you omit the password, livestreamer will ask for it.

Once logged in, the plugin makes sure to save the session credentials to avoid asking your username and password again.

Neverthless, these credentials are valid for a limited amount of time, so it might be a good idea to save your username and password in your configuration file anyway.

WARNING: The API this plugin uses isn't supposed to be available to use it on computers. The plugin tries to blend in as a valid device using custom headers and following the API usual flow (e.g. reusing credentials), but this does not assure that your account will be safe from being spotted for unusual behavior.

  HTTP proxy with Crunchyroll

You can use the --http-proxy and --https-proxy options (you need both since the plugin uses both protocols) to access the Crunchyroll servers through a proxy to be able to stream region locked content.

When doing this, it's very probable that you will get denied to access the stream; this occurs because the session and credentials used by the plugin where obtained when logged from your own region, and the server still assumes you're in that region.

For this, the plugin provides the --crunchyroll-purge-credentials option, which removes your saved session and credentials and tries to log in again using your username and password.

SIDELOADING PLUGINS

Livestreamer will attempt to load standalone plugins from these directories:
Platform | Location
Unix-like (POSIX) | $XDG_CONFIG_HOME/livestreamer/plugins
Windows | %APPDATA%\livestreamer\plugins

NOTE: If a plugin is added with the same name as a built-in plugin then the added plugin will take precedence. This is useful if you want to upgrade plugins independently of the Livestreamer version.

PLAYING BUILT-IN STREAMING PROTOCOLS DIRECTLY

There are many types of streaming protocols used by services today and Livestreamer supports most of them. It's possible to tell Livestreamer to access a streaming protocol directly instead of relying on a plugin to extract the streams from a URL for you.

A protocol can be accessed directly by specifying it in the URL format:

protocol://path [key=value]

Accessing a stream that requires extra parameters to be passed along (e.g. RTMP):

$ livestreamer "rtmp://streaming.server.net/playpath live=1 swfVfy=http://server.net/flashplayer.swf"

Most streaming technologies simply requires you to pass a HTTP URL, this is a Adobe HDS stream:

$ livestreamer hds://streaming.server.net/playpath/manifest.f4m

  Supported streaming protocols
Name | Prefix
Adobe HTTP Dynamic Streaming | hds://
Akamai HD Adaptive Streaming | akamaihd://
Apple HTTP Live Streaming | hls:// hlsvariant://
Real Time Messaging Protocol | rtmp:// rtmpe:// rtmps:// rtmpt:// rtmpte://
Progressive HTTP, HTTPS, etc | httpstream://

COMMAND-LINE USAGE

$ livestreamer [OPTIONS] [URL] [STREAM]

  Positional arguments

[URL]
    A URL to attempt to extract streams from.

    If it's a HTTP URL then "http://" can be omitted.

[STREAM]
    Stream to play.

    Use "best" or "worst" for highest or lowest quality available.

    Fallback streams can be specified by using a comma-separated list:

    "720p,480p,best"

    If no stream is specified and --default-stream is not used then a list of available streams will be printed.

  General options

-h, --help
    Show this help message and exit.

-V, --version
    Show version number and exit.

--plugins
    Print a list of all currently installed plugins.

--can-handle-url URL
    Check if Livestreamer has a plugin that can handle the specified URL.

    Returns status code 1 for false and 0 for true.

    Useful for external scripting.

--config FILENAME
    Load options from this config file.

    Can be repeated to load multiple files, in which case the options are merged on top of each other where the last config has highest priority.

-l LEVEL, --loglevel LEVEL
    Set the log message threshold.

    Valid levels are: none, error, warning, info, debug

-Q, --quiet
    Hide all log output.

    Alias for "--loglevel none".

-j, --json
    Output JSON representations instead of the normal text output.

    Useful for external scripting.

--no-version-check
    Do not check for new Livestreamer releases.

--version-check
    Runs a version check and exits.

  Player options

-p COMMAND, --player COMMAND
    Player to feed stream data to. This is a shell-like syntax to support passing options to the player. For example:

    "vlc --file-caching=5000"

    To use a player that is located in a path with spaces you must quote the path:

    "'/path/with spaces/vlc' --file-caching=5000"

    By default VLC will be used if it can be found in its default location.

-a ARGUMENTS, --player-args ARGUMENTS
    This option allows you to customize the default arguments which are put together with the value of --player to create a command to execute.

    This value can contain formatting variables surrounded by curly braces, { and }. If you need to include a brace character, it can be escaped by doubling, e.g. {{ and }}.

    Formatting variables available:

filename
    This is the filename that the player will use. It's usually "-" (stdin), but can also be a URL or a file depending on the options used.

    It's usually enough to use --player instead of this unless you need to add arguments after the filename.

    Default is: "{filename}".

-v, --verbose-player
    Allow the player to display its console output.

-n, --player-fifo, --fifo
    Make the player read the stream through a named pipe instead of the stdin pipe.

--player-http
    Make the player read the stream through HTTP instead of the stdin pipe.

--player-continuous-http
    Make the player read the stream through HTTP, but unlike --player-http it will continuously try to open the stream if the player requests it.

    This makes it possible to handle stream disconnects if your player is capable of reconnecting to a HTTP stream. This is usually done by setting your player to a "repeat mode".

--player-external-http
    Serve stream data through HTTP without running any player. This is useful to allow external devices like smartphones or streaming boxes to watch streams they wouldn't be able to otherwise.

    Behavior will be similar to the continuous HTTP option, but no player program will be started, and the server will listen on all available connections instead of just in the local (loopback) interface.

    The URLs that can be used to access the stream will be printed to the console, and the server can be interrupted using CTRL-C.

--player-external-http-port PORT
    A fixed port to use for the external HTTP server if that mode is enabled. Omit or set to 0 to use a random high (>1024) port.

--player-passthrough TYPES
    A comma-delimited list of stream types to pass to the player as a URL to let it handle the transport of the stream instead.

    Stream types that can be converted into a playable URL are:

•   hls

•   http

•   rtmp

    Make sure your player can handle the stream type when using this.

--player-no-close
    By default Livestreamer will close the player when the stream ends. This is to avoid "dead" GUI players lingering after a stream ends.

    It does however have the side-effect of sometimes closing a player before it has played back all of its cached data.

    This option will instead let the player decide when to exit.

  File output options

-o FILENAME, --output FILENAME
    Write stream data to FILENAME instead of playing it.

    You will be prompted if the file already exists.

-f, --force
    When using -o, always write to file even if it already exists.

-O, --stdout
    Write stream data to stdout instead of playing it.

  Stream options

--default-stream STREAM
    Open this stream when no stream argument is specified, e.g. "best".

--retry-streams DELAY
    Will retry fetching streams until streams are found while waiting DELAY (seconds) between each attempt.

--retry-open ATTEMPTS
    Will try ATTEMPTS times to open the stream until giving up.

    Default is: 1.

--stream-types TYPES, --stream-priority TYPES
    A comma-delimited list of stream types to allow.

    The order will be used to separate streams when there are multiple streams with the same name but different stream types.

    Default is: "rtmp,hls,hds,http,akamaihd".

--stream-sorting-excludes STREAMS
    Fine tune best/worst synonyms by excluding unwanted streams.

    Uses a filter expression in the format:

    [operator]<value>

    Valid operators are >, >=, < and <=. If no operator is specified then equality is tested.

    For example this will exclude streams ranked higher than "480p":

    ">480p"

    Multiple filters can be used by separating each expression with a comma.

    For example this will exclude streams from two quality types:

    ">480p,>medium"

  Stream transport options

--hds-live-edge SECONDS
    The time live HDS streams will start from the edge of stream.

    Default is: 10.0.

--hds-segment-attempts ATTEMPTS
    How many attempts should be done to download each HDS segment before giving up.

    Default is: 3.

--hds-segment-threads THREADS
    The size of the thread pool used to download HDS segments. Minimum value is 1 and maximum is 10.

    Default is: 1.

--hds-segment-timeout TIMEOUT
    HDS segment connect and read timeout.

    Default is: 10.0.

--hds-timeout TIMEOUT
    Timeout for reading data from HDS streams.

    Default is: 60.0.

--hls-live-edge SEGMENTS
    How many segments from the end to start live HLS streams on.

    The lower the value the lower latency from the source you will be, but also increases the chance of buffering.

    Default is: 3.

--hls-segment-attempts ATTEMPTS
    How many attempts should be done to download each HLS segment before giving up.

    Default is: 3.

--hls-segment-threads THREADS
    The size of the thread pool used to download HLS segments. Minimum value is 1 and maximum is 10.

    Default is: 1.

--hls-segment-timeout TIMEOUT
    HLS segment connect and read timeout.

    Default is: 10.0.

--hls-timeout TIMEOUT
    Timeout for reading data from HLS streams.

    Default is: 60.0.

--http-stream-timeout TIMEOUT
    Timeout for reading data from HTTP streams.

    Default is: 60.0.

--ringbuffer-size SIZE
    The maximum size of ringbuffer. Add a M or K suffix to specify mega or kilo bytes instead of bytes.

    The ringbuffer is used as a temporary storage between the stream and the player. This is to allows us to download the stream faster than the player wants to read it.

    The smaller the size, the higher chance of the player buffering if there are download speed dips and the higher size the more data we can use as a storage to catch up from speed dips.

    It also allows you to temporary pause as long as the ringbuffer doesn't get full since we continue to download the stream in the background.

    NOTE: A smaller size is recommended on lower end systems (such as Raspberry Pi) when playing stream types that require some extra processing (such as HDS) to avoid unnecessary background processing.

    Default is: "16M".

--rtmp-proxy PROXY, --rtmpdump-proxy PROXY
    A SOCKS proxy that RTMP streams will use.

    Example: 127.0.0.1:9050

--rtmp-rtmpdump FILENAME, --rtmpdump FILENAME, -r FILENAME
    RTMPDump is used to access RTMP streams. You can specify the location of the rtmpdump executable if it is not in your PATH.

    Example: "/usr/local/bin/rtmpdump"

--rtmp-timeout TIMEOUT
    Timeout for reading data from RTMP streams.

    Default is: 60.0.

--stream-segment-attempts ATTEMPTS
    How many attempts should be done to download each segment before giving up.

    This is generic option used by streams not covered by other options, such as stream protocols specific to plugins, e.g. UStream.

    Default is: 3.

--stream-segment-threads THREADS
    The size of the thread pool used to download segments. Minimum value is 1 and maximum is 10.

    This is generic option used by streams not covered by other options, such as stream protocols specific to plugins, e.g. UStream.

    Default is: 1.

--stream-segment-timeout TIMEOUT
    Segment connect and read timeout.

    This is generic option used by streams not covered by other options, such as stream protocols specific to plugins, e.g. UStream.

    Default is: 10.0.

--stream-timeout TIMEOUT
    Timeout for reading data from streams.

    This is generic option used by streams not covered by other options, such as stream protocols specific to plugins, e.g. UStream.

    Default is: 60.0.

--stream-url
    If possible, translate the stream to a URL and print it.

--subprocess-cmdline, --cmdline, -c
    Print command-line used internally to play stream.

    This is only available on RTMP streams.

--subprocess-errorlog, --errorlog, -e
    Log possible errors from internal subprocesses to a temporary file. The file will be saved in your systems temporary directory.

    Useful when debugging rtmpdump related issues.

  HTTP options

--http-proxy HTTP_PROXY
    A HTTP proxy to use for all HTTP requests.

    Example: http://hostname:port/

--https-proxy HTTPS_PROXY
    A HTTPS capable proxy to use for all HTTPS requests.

    Example: http://hostname:port/

--http-cookie KEY=VALUE
    A cookie to add to each HTTP request.

    Can be repeated to add multiple cookies.

--http-header KEY=VALUE
    A header to add to each HTTP request.

    Can be repeated to add multiple headers.

--http-query-param KEY=VALUE
    A query parameter to add to each HTTP request.

    Can be repeated to add multiple query parameters.

--http-ignore-env
    Ignore HTTP settings set in the environment such as environment variables (HTTP_PROXY, etc) or ~/.netrc authentication.

--http-no-ssl-verify
    Don't attempt to verify SSL certificates.

    Usually a bad idea, only use this if you know what you're doing.

--http-ssl-cert FILENAME
    SSL certificate to use.

    Expects a .pem file.

--http-ssl-cert-crt-key CRT_FILENAME KEY_FILENAME
    SSL certificate to use.

    Expects a .crt and a .key file.

--http-timeout TIMEOUT
    General timeout used by all HTTP requests except the ones covered by other options.

    Default is: 20.0.

  Plugin options

--plugin-dirs DIRECTORY
    Attempts to load plugins from these directories.

    Multiple directories can be used by separating them with a semi-colon.

--twitch-oauth-token TOKEN
    An OAuth token to use for Twitch authentication. Use --twitch-oauth-authenticate to create a token.

--twitch-oauth-authenticate
    Open a web browser where you can grant Livestreamer access to your Twitch account which creates a token for use with --twitch-oauth-token.

--twitch-cookie COOKIES
    Twitch cookies to authenticate to allow access to subscription channels.

    Example:

    "_twitch_session_id=xxxxxx; persistent=xxxxx"

    NOTE: This method is the old and clunky way of authenticating with Twitch, using --twitch-oauth-authenticate is the recommended and simpler way of doing it now.

--ustream-password PASSWORD
    A password to access password protected UStream.tv channels.

--crunchyroll-username USERNAME
    A Crunchyroll username to allow access to restricted streams.

--crunchyroll-password [PASSWORD]
    A Crunchyroll password for use with --crunchyroll-username.

    If left blank you will be prompted.

--crunchyroll-purge-credentials
    Purge cached Crunchyroll credentials to initiate a new session and reauthenticate.

--livestation-email EMAIL
    A Livestation account email to access restricted or premium quality streams.

--livestation-password PASSWORD
    A Livestation account password to use with --livestation-email.

AUTHOR
Christopher Rosell

COPYRIGHT
2011-2015, Christopher Rosell