StreamGear API¶
Overview¶
StreamGear streamlines and simplifies the transcoding workflow to generate Ultra-Low Latency, High-Quality, Dynamic & Adaptive Streaming Formats like MPEG-DASH and Apple HLS with just a few lines of Python code, allowing developers to focus on their application logic rather than dealing with the complexities of transcoding and chunking media files.
StreamGear API provides a standalone, highly extensible, and flexible wrapper around the FFmpeg multimedia framework for generating chunk-encoded media segments from your multimedia content effortlessly.
With StreamGear, you can transcode source video/audio files and real-time video frames into a sequence of multiple smaller chunks/segments of suitable lengths. These segments facilitate streaming at different quality levels (bitrates or spatial resolutions) and allow for seamless switching between quality levels during playback based on available bandwidth. You can serve these segments on a web server, making them easily accessible via standard HTTP GET requests.
SteamGear currently supports both MPEG-DASH (Dynamic Adaptive Streaming over HTTP, ISO/IEC 23009-1) and Apple HLS (HTTP Live Streaming).
Additionally, StreamGear generates a manifest file (such as MPD for DASH) or a master playlist (such as M3U8 for Apple HLS) alongside the segments. These files contain essential segment information, including timing, URLs, and media characteristics like video resolution and adaptive bitrate. They are provided to the client before the streaming session begins.
For streaming with older traditional protocols such as RTMP, RTSP/RTP you could use WriteGear API instead.
New in v0.2.2
Apple HLS support was added in v0.2.2
.
Important
-
StreamGear MUST requires FFmpeg executables for its core operations. Follow these dedicated Platform specific Installation Instructions ➶ for its installation.
-
StreamGear API will throw RuntimeError, if it fails to detect valid FFmpeg executable on your system.
-
It is advised to enable logging (
logging=True
) on the first run for easily identifying any runtime errors.
Useful Links
- Checkout this detailed blogpost ➶ on how MPEG-DASH works.
- Checkout this detailed blogpost ➶ on how HLS works.
- Checkout this detailed blogpost ➶ for HLS vs. MPEG-DASH comparison.
Mode of Operations¶
StreamGear primarily operates in following independent modes for transcoding:
Real-time Frames Mode itself is NOT Live-Streaming
To enable live-streaming in Real-time Frames Mode, use the exclusive -livestream
attribute of the stream_params
dictionary parameter in the StreamGear API. Checkout this usage example ➶ for more information.
-
Single-Source Mode : In this mode, StreamGear transcodes entire video file (as opposed to frame-by-frame) into a sequence of multiple smaller chunks/segments for streaming. This mode works exceptionally well when you're transcoding long-duration lossless videos(with audio) for streaming that required no interruptions. But on the downside, the provided source cannot be flexibly manipulated or transformed before sending onto FFmpeg Pipeline for processing.
-
Real-time Frames Mode : In this mode, StreamGear directly transcodes frame-by-frame (as opposed to a entire video file), into a sequence of multiple smaller chunks/segments for streaming. This mode works exceptionally well when you desire to flexibility manipulate or transform
numpy.ndarray
frames in real-time before sending them onto FFmpeg Pipeline for processing. But on the downside, audio has to added manually (as separate source) for streams.
Watch Demo¶
Watch StreamGear transcoded MPEG-DASH Stream:
Powered by clappr & shaka-player
This video assets (Manifest and segments) are hosted on GitHub Repository and served with raw.githack.com
Video Credits: "Tears of Steel" - Project Mango Teaser
Watch StreamGear transcoded APPLE HLS Stream:
Powered by clappr & HlsjsPlayback
This video assets (Playlist and segments) are hosted on GitHub Repository and served with raw.githack.com
Video Credits: "Sintel" - Project Durian Teaser
Recommended Players¶
- MPV Player: (recommended) MPV is a free, open source, and cross-platform media player. It supports a wide variety of media file formats, audio and video codecs, and subtitle types.
- VLC Player: VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs, and various streaming protocols.
- Parole: (UNIX only) Parole is a modern simple media player based on the GStreamer framework for Unix and Unix-like operating systems.
- MP4Client: GPAC provides a highly configurable multimedia player called MP4Client. GPAC itself is an open source multimedia framework developed for research and academic purposes, and used in many media production chains.
- ffplay: FFplay is a very simple and portable media player using the FFmpeg libraries and the SDL library. It is mostly used as a testbed for the various FFmpeg APIs.
To run Online players locally, you'll need a HTTP server. For creating one yourself, See this well-curated list ➶
- Clapper: Clappr is an extensible media player for the web.
- Shaka Player: Shaka Player is an open-source JavaScript library for playing adaptive media in a browser.
- MediaElementPlayer: MediaElementPlayer is a complete HTML/CSS audio/video player.
- Native MPEG-Dash + HLS Playback(Chrome Extension): Allow the browser to play HLS (m3u8) or MPEG-Dash (mpd) video urls 'natively' on chrome browsers.
Parameters¶
References¶
FAQs¶