HLS Streaming Protocol
A software engineer discusses the principles behind the HLS streaming protocol that's built on HTTP and allows for video/audio data transfer.
Join the DZone community and get the full member experience.
Join For FreeHLS (HTTP Live Streaming)
HLS is an HTTP-based streaming protocol.
Before starting with the protocol, we need to understand the fundamentals of digital videos. Refer to the below link for a basic understanding of video components.
Reference: https://www.cisco.com/c/en/us/td/docs/solutions/Enterprise/Video/pktvideoaag.html
HLS works by breaking down a stream into a sequence of small packets. As the stream is played, the client selects a number of different alternative streams containing the same information encoded with a variety of data rates. It allows for streaming sessions to take data from various data rates.
At the start of a streaming session, HLS downloads one file with the extension M3U (and m3u8 if the UTF-8 encoding-character coded format is used). It contains the specific location of one or more media files. It is commonly used to point media players to audio and video sources.
An M3U file is a plain text file that specifies the locations of one or more media files.
Reference: https://www.lifewire.com/m3u-file-2621955
HLS uses HTTP-base transactions over TCP, unlike the RTP protocol transaction over UDP.
HTTP live streaming uses a web server (network protocol to distribute information over world wide web) to distribute streaming content. The primary function of a web server is to store, process, and deliver web pages or clients.
The server codifies and encapsulates input videos into the proper format for delivery. Videos are then prepared for distribution by segmenting them into different files. The video is thus transformed into fragmented and indexed files.
Audio/video data is encapsulated and formated as a PES packet (packetized elementary stream (actual video.audio data), which is then bound with the TS packet.) This is later attached with MPEG transport stream.
Don't confuse MJPEG with MPEG2TS. MJPEG is a codec that has video information and MPEG2TS is a container that enables the transfer of stream data.
NOTE:
Codec - "A codec is a method for encoding and decoding data and more specifically, a protocol for compressing data, especially video."
Container - "The container takes care of packaging, transport, and presentation. The container is usually represented by a file extension. For example, the MPEG4 container is usually represented by a .mp4 file type."
The MPEG transport stream (mjpeg2ts) is a standard digital container format for transmission and storage of audio and video data. It's used for broadcast systems such as digital video broadcasting (ATSC and IPTV).
Reference:https://en.wikipedia.org/wiki/MPEG_transport_stream
Block diagram:
References
Opinions expressed by DZone contributors are their own.
Comments