You are reading the documentation for the in-development version of Streamlink.
Stream¶
All streams inherit from the Stream
base class.
- class streamlink.stream.Stream(session)¶
Bases:
object
This is a base class that should be inherited when implementing different stream types. Should only be created by plugins.
- Parameters:
session (Streamlink) -- Streamlink session instance
- open()¶
Attempts to open a connection to the stream. Returns a file-like object that can be used to read the stream data.
- Raises:
StreamError -- on failure
- Return type:
StreamIO
- class streamlink.stream.MuxedStream(session, *substreams, **options)¶
Bases:
Stream
,Generic
[TSubstreams
]Muxes multiple streams into one output stream.
- Parameters:
session (streamlink.Streamlink) -- Streamlink session instance
substreams (TSubstreams) -- Video and/or audio streams
options -- Additional keyword arguments passed to
ffmpegmux.FFMPEGMuxer
. Subtitle streams need to be set via thesubtitles
keyword.
- class streamlink.stream.HTTPStream(session, url, buffered=True, **kwargs)¶
Bases:
Stream
An HTTP stream using the
requests
library.- Parameters:
session (Streamlink) -- Streamlink session instance
url (str) -- The URL of the HTTP stream
buffered (bool) -- Wrap stream output in an additional reader-thread
kwargs -- Additional keyword arguments passed to
requests.Session.request()
- args: dict¶
A dict of keyword arguments passed to
requests.Session.request()
, such as method, headers, cookies, etc.
- class streamlink.stream.HLSStream(session, url, url_master=None, multivariant=None, force_restart=False, start_offset=0, duration=None, **kwargs)¶
Bases:
HTTPStream
Implementation of the Apple HTTP Live Streaming protocol.
- Parameters:
session (Streamlink) -- Streamlink session instance
url (str) -- The URL of the HLS playlist
url_master (str | None) -- The URL of the HLS playlist's multivariant playlist (deprecated)
multivariant (M3U8 | None) -- The parsed multivariant playlist
force_restart (bool) -- Start from the beginning after reaching the playlist's end
start_offset (float) -- Number of seconds to be skipped from the beginning
duration (float | None) -- Number of seconds until ending the stream
kwargs -- Additional keyword arguments passed to
requests.Session.request()
- classmethod parse_variant_playlist(session, url, name_key='name', name_prefix='', check_streams=False, force_restart=False, name_fmt=None, start_offset=0, duration=None, **kwargs)¶
Parse a variant playlist and return its streams.
- Parameters:
session (Streamlink) -- Streamlink session instance
url (str) -- The URL of the variant playlist
name_key (str) -- Prefer to use this key as stream name, valid keys are: name, pixels, bitrate
name_prefix (str) -- Add this prefix to the stream names
check_streams (bool) -- Only allow streams that are accessible
force_restart (bool) -- Start at the first segment even for a live stream
name_fmt (str | None) -- A format string for the name, allowed format keys are: name, pixels, bitrate
start_offset (float) -- Number of seconds to be skipped from the beginning
duration (float | None) -- Number of second until ending the stream
kwargs -- Additional keyword arguments passed to
HLSStream
,MuxedHLSStream
, orrequests.Session.request()
- Return type:
dict[str, HLSStream | MuxedHLSStream]
- property url_master¶
Deprecated
- class streamlink.stream.MuxedHLSStream(session, video, audio, hlsstream=None, url_master=None, multivariant=None, force_restart=False, ffmpeg_options=None, **kwargs)¶
Bases:
MuxedStream
[HLSStream
]Muxes multiple HLS video and audio streams into one output stream.
- Parameters:
session (Streamlink) -- Streamlink session instance
video (str) -- Video stream URL
audio (str | list[str]) -- Audio stream URL or list of URLs
hlsstream (type[HLSStream] | None) -- The
HLSStream
class of each sub-streamurl_master (str | None) -- The URL of the HLS playlist's multivariant playlist (deprecated)
multivariant (M3U8 | None) -- The parsed multivariant playlist
force_restart (bool) -- Start from the beginning after reaching the playlist's end
ffmpeg_options (Mapping[str, Any] | None) -- Additional keyword arguments passed to
ffmpegmux.FFMPEGMuxer
kwargs -- Additional keyword arguments passed to
HLSStream
- property url_master¶
Deprecated
- class streamlink.stream.DASHStream(session, mpd, video_representation=None, audio_representation=None, **kwargs)¶
Bases:
Stream
Implementation of the "Dynamic Adaptive Streaming over HTTP" protocol (MPEG-DASH)
- Parameters:
session (Streamlink) -- Streamlink session instance
mpd (MPD) -- Parsed MPD manifest
video_representation (Representation | None) -- Video representation
audio_representation (Representation | None) -- Audio representation
kwargs -- Additional keyword arguments passed to
requests.Session.request()
- classmethod parse_manifest(session, url_or_manifest, period=0, with_video_only=False, with_audio_only=False, **kwargs)¶
Parse a DASH manifest file and return its streams.
- Parameters:
session (Streamlink) -- Streamlink session instance
url_or_manifest (str) -- URL of the manifest file or an XML manifest string
period (int) -- Which MPD period to use (index number) for finding representations
with_video_only (bool) -- Also return video-only streams, otherwise only return muxed streams
with_audio_only (bool) -- Also return audio-only streams, otherwise only return muxed streams
kwargs -- Additional keyword arguments passed to
requests.Session.request()
- Return type:
dict[str, DASHStream]