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.Stream(session)¶
Bases:
objectThis 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.ffmpegmux.MuxedStream(session, *substreams, **options)¶
Bases:
Stream,Generic[TSubstreams_co]Muxes multiple streams into one output stream.
- Parameters:
session (streamlink.Streamlink) -- Streamlink session instance
substreams (TSubstreams_co) -- Video and/or audio streams
options -- Additional keyword arguments passed to
ffmpegmux.FFMPEGMuxer. Subtitle streams need to be set via thesubtitleskeyword.
- class streamlink.stream.http.HTTPStream(session, url, buffered=True, **kwargs)¶
Bases:
StreamAn HTTP stream using the
requestslibrary.- 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.hls.HLSStream(session, url, multivariant=None, name=None, force_restart=False, start_offset=0, duration=None, **kwargs)¶
Bases:
HTTPStreamImplementation of the Apple HTTP Live Streaming protocol.
- Parameters:
session (Streamlink) -- Streamlink session instance
url (str) -- The URL of the HLS playlist
multivariant (M3U8 | None) -- The parsed multivariant playlist
name (str | None) -- Optional name suffix for the stream's worker and writer threads
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 | Literal['playlists', 'segments']) -- Only return streams which are accessible. Set to
Trueor"playlists"to check whether media playlists are accessible, or set to"segments"to check segment accessibility as well. Only one segment of the first available media playlist is checked to optimize loading times.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, Self | MuxedHLSStream[Self]]
- class streamlink.stream.hls.MuxedHLSStream(session, video, audio, hlsstream=None, multivariant=None, force_restart=False, ffmpeg_options=None, **kwargs)¶
Bases:
MuxedStream[TMuxedHLSStream_co]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[TMuxedHLSStream_co] | None) -- The
HLSStreamclass of each sub-streammultivariant (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.FFMPEGMuxerkwargs -- Additional keyword arguments passed to
HLSStream
- class streamlink.stream.dash.DASHStream(session, mpd, video_representation=None, audio_representation=None, duration=None, **kwargs)¶
Bases:
StreamImplementation 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
duration (float | None) -- Number of seconds until ending the stream
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 | str) -- Which MPD period to use (index number (int) or
idattribute (str)) for finding representationswith_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
DASHStreamorrequests.Session.request()
- Return type:
dict[str, DASHStream]