Adaptive bitrate streaming
Adaptive bitrate streaming in ImageKit
Adaptive bitrate streaming (ABS) enables the optimum streaming video viewing experience for different types of devices over a broad set of connection speeds. This results in very little buffering, a fast start time and a good experience for both high-end and low-end connections.
The client (e.g. a video player) loads the manifest file and then chooses an appropriate segment, usually starting from the lowest bit rate stream to speed up initial playback. If network throughput is greater than the bit rate of the downloaded segment, it requests a higher bit rate segment. The client continues to adapt to changes in network throughput to ensure a smooth playback experience. The exact algorithm of choosing which segment to load can vary from client to client but fundamentally it remains the same -- choose the appropriate segment and adapt as network (or other device constraints) changes.
For ABS to work, the client needs a manifest file that contains information about segments of different variants at varying bitrates. ImageKit can generate and deliver all necessary variants and manifest files from a single source video that is accessible through your ImageKit's account. The original video can be hosted in the ImageKit media library or external storage integrated with ImageKit. Extra storage created because of generated variants and manifest files is counted towards your media library storage.
ImageKit supports the following streaming protocols. Both leverage existing HTTP infrastructure including CDN caching.
- HTTP Live Streaming (HLS)
- Dynamic Adaptive Streaming over HTTP (MPEG-DASH) protocol
See the live demo along with code examples here - https://imagekit.io/use-cases/adaptive-bitrate-streaming-videos/
The following URL will generate HLS manifest and five variants at differernt resolutions i.e. 240p, 360p, 480p, 720p and 1080p.
The following URL will generate DASH manifest and five variants at differernt resolutions i.e. 240p, 360p, 480p, 720p and 1080p.
The first time you access the manifest URL, a
202HTTP status code is returned with an empty response. In the background, ImageKit will generate the required variants as per the value of
sr. It could take up to a minute or two for this to finish. This also depends on video file size and your origin location. The next time you request the same URL, a manifest file is returned in the response with a
sr-<representations>transformation to generate the master manifest file for DASH along with necessary variants and segments.
representationsis the list of different representations you want to create separated by an underscore
sr-<representations>transformation is used to specify representations you want to create separated by an underscore
_. Here is the list of supported representations for both HLS and DASH.
ImageKit uses H.264 codec for encoding video and AAC for encoding audio for both HLS and DASH.
Important note for existing users All ABS representations created after 25th April, 2023 will use at_max cropping strategy to resize the representations instead of current pad_resize crop mode. Output will match the aspect ratio of the original video after this change. Learn more
You can transform the final video using any supported video transformation parameter in ImageKit except