HLS Playback¶
Flussonic Media Server supports playing video via the HLS protocol. Many of Flussonic's HLS features use non-standard extensions of HLS – we support them for your convenience.
The supported codecs are: H264, H265, MPEG2 video, AAC, MP3, MPEG2 audio, and AC-3.
Flussonic Media Server supports access via HLS to live streams, VOD files and DVR (catchup and timeshift).
If an incoming stream has DVB subtitles or teletext, then Flussonic can pass them to an output HLS stream if you configure Flussonic for that. Subtitles are saved in DVR archive if a stream is recorded to the archive.
On this page:
- Structure of HLS protocol
- General standard HLS playback
- HLS playback as fragmented MP4
- Low-Latency HLS
- Multilanguage HLS
- Adding 'Audio only' for Apple devices
- DVR catchup playback
- Rewinding a playlist
- DVR timeshift playback
- Playing individual tracks
- Sorting tracks in multibitrate playlist
- HLS playback with thumbnails
Structure of HLS protocol¶
HLS protocol works by breaking the overall stream or file into a sequence of media segments of equal length. The segments are represented by .ts
files sequentially downloaded by HTTP.
HLS also creates an index file that contains references of media segment files, saved as .m3u8
.
Depending on usage scenario, you can use different URLs for HLS playback, but in any case, the URL will result in one of the following two types of playlists (or manifests).
Media Playlist¶
Media Playlist is a playlist where all lines identify media segments. Each media segment is specified by a URI and has the .ts
extension. The playlist continues to be updated as new media URIs are added.
Such a playlist is used for playing simple streams or files with only one video track and one audio track.
Media Playlist example:
#EXTM3U
#EXT-X-TARGETDURATION:7
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:38530
#EXT-X-PROGRAM-DATE-TIME:2022-03-22T08:06:37Z
#EXTINF:5.000,
2022/03/22/08/06/37-05000.ts
#EXTINF:5.000,
2022/03/22/08/06/42-05000.ts
#EXTINF:5.000,
2022/03/22/08/06/47-05000.ts
#EXTINF:5.000,
2022/03/22/08/06/52-05000.ts
Master Playlist¶
Master Playlist is a playlist where all lines identify Media Playlists. Each Media Playlist is specified by a URI and has the .m3u8
extension. Master playlist may be used for multibitrate playback and allows clients to switch between bitrates dynamically.
Master Playlist example:
#EXTM3U
#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=640x480,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=500000,BANDWIDTH=630000
tracks-v3a1/mono.m3u8
#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=768x576,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=610000,BANDWIDTH=770000
tracks-v2a1/mono.m3u8
#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=960x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=650000,BANDWIDTH=820000
tracks-v1a1/mono.m3u8
General standard HLS playback¶
When you have a simple live stream or file (one video track, one audio track) for playing, the URL for playback via HLS is simple:
http://FLUSSONIC-IP/STREAM_NAME/index.m3u8
where FLUSSONIC-IP
stands for your Flussonic Media Server host + port address.
Flussonic Media Server will also accept playlist.m3u8
in the end of the URL for backward compatibility with other servers.
With multilanguage or multi-bitrate content, there is a number of peculiarities in URL that are described further on this page.
HLS playback of fMP4 for H.265¶
Fragmented MP4 (fMP4) offers important benefits. First of all, it is the only way to play HEVC video via the HLS. Besides, the MP4 container is supported by any player, in contrast with MPEG. The fMP4 format can also used by DASH, so that only the manifest would be different from HLS while the MP4 encoding would be performed once for both protocols.
The following URL allows HLS playback as fMP4 chunks:
http://FLUSSONIC-IP/STREAM_NAME/index.fmp4.m3u8
where FLUSSONIC-IP
stands for your Flussonic Media Server host + port address.
Playback via Low-Latency HLS¶
Flussonic allows playback via Apple Low-Latency HLS (LL-HLS).
Multilanguage HLS¶
If you want to play your multilanguage stream on iPhone you need to use the same http://flussonic-ip/STREAM_NAME/index.m3u8
But when you want to watch a multi-language stream using VLC or a set-top box, the video
mode must be turned on.
URL for the player will be:
http://FLUSSONIC-IP/STREAM_NAME/video.m3u8
This is due to the Apple HLS requirement of a separate playlist with an audio-only option for each individual language. MPEG-TS uses another algorithm: all audio tracks are packed in the same container with the video, and it is up to the player which one to play. So, to make sure the video is viewable on iPhone, it must satisfy the requirements of Apple. At the same time, VLC and STBs, in violation of the HLS standard, expect the old version of MPEG-TS converted to HLS. This is why this trick with different URLs is needed.
Adding 'Audio only' for Apple devices¶
Apple requires that all your streams must include a version without video, only with audio.
They suppose that if a user is watching video via 3G and has moved to a zone with bad network conditions, it would be better to have audio only than video with buffering.
Flussonic allows you to enable audio-only mode in the following way:
stream example {
input file://vod/bunny.mp4;
add_audio_only;
}
Note
Such a configuration might make your index.m3u8
URL unplayable on VLC or STB — in that case use video.m3u8
option (described earlier on this page).
Separate playlists for STBs¶
If you have a multi-bitrate multilanguage content and want to play it on STB that doesn't support multi-bitrate HLS playlists, you can request from Flussonic Media Server separate playlists with one video track and all audio tracks like with the mono
option:
http://FLUSSONIC-IP/STREAM_NAME/mono.m3u8
This playlist is not a variant (multi-bitrate) playlist, but it is a playlist with URLs to segments that contain the first video track and all available audio tracks.
If you want to deliver multi-language multi-bitrate to STB that doesn't understand Apple standard for multilanguage, use video.m3u8
:
http://FLUSSONIC-IP/STREAM_NAME/video.m3u8
This is a variant playlist that will give you a list of non-variant playlists like video1.m3u8
, video2.m3u8
, etc.
Separate audio playlists¶
Some Smart TVs (like Samsung TV) and browsers, supporting the MSE (Media Source Extensions) standard, cannot switch between the audio tracks if HLS stream has multiple audio tracks encoded (for instance, for different languages). As a result, players do not display these audio tracks, or a stream might not be played at all.
Flussonic can create a playlist with separate audio for such cases. To enable this feature, add separate_audio=true
in the query string to request the HLS playlist for the player:
http://FLUSSONIC-IP/STREAM_NAME/index.m3u8?separate_audio=true
So the playlist will looks as follows:
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="eng a1",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="eng",URI="tracks-a1/mono.m3u8"
#EXT-X-STREAM-INF:AUDIO="aac",CLOSED-CAPTIONS=NONE,RESOLUTION=320x240,FRAME-RATE=25.000,CODECS="avc1.420015,mp4a.40.2",AVERAGE-BANDWIDTH=240000,BANDWIDTH=310000
tracks-v1/mono.m3u8
It works for Live, VOD, and DVR playlists.
This is how to request such a playlist for DVR:
http://FLUSSONIC-IP/STREAM_NAME/archive-1643098810-30.m3u8?separate_audio=true
The output would look like so:
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="eng a1",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="eng",URI="tracks-a1/index-1643098810-30.m3u8"
#EXT-X-STREAM-INF:AUDIO="aac",CLOSED-CAPTIONS=NONE,RESOLUTION=320x240,FRAME-RATE=25.000,CODECS="avc1.420015,mp4a.40.2",AVERAGE-BANDWIDTH=240000,BANDWIDTH=300000
tracks-v1/index-1643098810-30.m3u8
HLS DVR playback¶
DVR catchup playback¶
When your stream is already recorded on the server with our DVR you can play video via HLS when you know the beginning and the duration of a telecast, for example, from EPG.
Available URLs will be:
http://FLUSSONIC-IP/STREAM_NAME/archive-1659507585-3600.m3u8
This is a regular playlist that will be variant playlist if you have more than one language or more than one bitrate.
This playlist has the VOD (static) type. It contains a list of segments starting from UTC 1659507585 (2022, August, 3th, 06:19:45 GMT) and for one hour forward. No changes will be made to this playlist.
You may request the playlist of the EVENT (append-only) type if the end of the requested period is in the present or future. Add event=true
in the above URL for that. Such a playlist will contain a list of segments starting from UTC 1659507585 (2022, August, 3th, 06:19:45 GMT) up to the current moment. New segments will be appended to this playlist, but all previously seen segments will be kept. If you use the same URL after some time, when the specified end of period will become the past, the playlist will get the VOD type.
The mono
URL will give you list of segments that contain all tracks in MPEG-TS:
http://FLUSSONIC-IP/STREAM_NAME/mono-1659507585-3600.m3u8
More specific videoN
playlist will give you a list of segments with an N'th video track and all audio tracks:
http://FLUSSONIC-IP/STREAM_NAME/video1-1659507585-3600.m3u8
and a variant video playlist with a list of videoN
playlists that can be used for old STB and VLC:
http://FLUSSONIC-IP/STREAM_NAME/video-1659507585-3600.m3u8
Note
Please don’t use video
URL for browsers and modern clients. In most cases, we recommend to use the regular archive
URL for getting playlist for video with multiple bitrates or multiple languages.
HLS Event playlist¶
You can access Event playlist with the URL:
http://FLUSSONIC-IP/STREAM_NAME/index-1659507585-now.m3u8
Event playlists are used when you want to allow the user to seek to any point within the event, e.g webinar, concert, current tv show. Such a playlist will contain a list of segments starting from UTC 1659507585 (2022, August, 3th, 06:19:45 GMT) up to the current moment. New segments will be appended to this playlist, but all previously seen segments will be kept.
Please notice that player will start playback from the live, not from the requested timecode, to access DVR data you should seek into the past.
Rewinding a playlist¶
Flussonic Media Server has a special playlist "rewind-N.m3u8" with a wide sliding window that allows to rewind and pause HLS streams for many hours.
http://FLUSSONIC-IP/STREAM_NAME/rewind-7200.m3u8
7200 is a duration of a HLS manifest in seconds, so your clients will be able to pause the stream up to two hours or rewind to the start of TV show without accessing catchup URLs.
DVR timeshift playback¶
If your stream is being recorded on disk but you haven't configured a timeshifted stream for it, then you can play timeshifted video via HLS by using a propely constructed URL.
Relative timeshift:
- Playing
ago
seconds back in time:http://FLUSSONIC-IP:PORT/STREAM_NAME/timeshift_rel-{ago}.m3u8
Absolute timeshift:
- Playing
from
UTC moment in time:http://FLUSSONIC-IP:PORT/STREAM_NAME/timeshift_abs-{from}.m3u8
DVR fMP4 over HLS¶
Similar URL formats as for usual HLS are supported for playing fMP4 DVR over HLS:
- DVR catchup:
http://FLUSSONIC-IP:PORT/STREAM_NAME/archive-{from}-{depth}.fmp4.m3u8
- DVR window:
http://FLUSSONIC-IP:PORT/STREAM_NAME/index-{from}-{duration}.fmp4.m3u8
- Event playlist:
http://FLUSSONIC-IP:PORT/STREAM_NAME/archive-{from}-now.fmp4.m3u8
- Rewind:
http://FLUSSONIC-IP:PORT/STREAM_NAME/rewind-{ago}.fmp4.m3u8
- Absolute DVR timeshift:
http://FLUSSONIC-IP:PORT/STREAM_NAME/timeshift_abs-{from}.fmp4.m3u8
- Relative DVR timeshift:
http://FLUSSONIC-IP:PORT/STREAM_NAME/timeshift_rel-{ago}.fmp4.m3u8
Learn more about playing fMP4 over HLS in the section above.
Playing individual tracks¶
If a stream has several audio and video tracks, you can specify which tracks should be delivered. To do so, specify the track numbers by adding the parameter filter.tracks
to the stream's URL.
Examples:
- Select the first audio and second video tracks:
http://FLUSSONIC-IP/STREAM_NAME/index.m3u8?filter.tracks=v2a1
- Select video only:
http://FLUSSONIC-IP/STREAM_NAME/index.m3u8?filter.tracks=v1
- Select the second video track and the first audio track to play the DVR archive section starting from UTC 1362504585 and with the duration of 3600 seconds:
http://FLUSSONIC-IP/STREAM_NAME/archive-1362504585-3600.m3u8?filter.tracks=v2a1
Sorting tracks in multibitrate playlist¶
If a multibitrate stream is used, all tracks are listed in the master playlist. By default, video tracks are sorted by bitrate in ascending order, i.e., playback starts from the video track with the lowest bitrate.
If you want to change the order of the tracks and start playing from another track, you can use the parameter filter.tracks
for this purpose. Specify video and audio track numbers in this parameter in the desired order, and the tracks in the playlist will be sorted correspondingly. For example:
http://FLUSSONIC-IP/STREAM_NAME/index.m3u8?filter.tracks=v3v2v1a2a1
In this case default tracks will be v3
and a2
.
HLS playback with thumbnails¶
It is possible to add thumbnails into HLS playlist as special tags that a player can read. It works both for streams with DVR enabled and for VOD files.
To include thumbnails into the playlist, add ?thumbnails=
option to the stream or the VOD file URL.
Example for a DVR window:
http://flussonic:80/ort/index-1644304617-60.m3u8?thumbnails=50
Example for a VOD file:
http://flussonic:80/vod/bunny.mp4/index.m3u8?thumbnails=100
This value defines how many thumbnail links will be added to the thumbnail playlist to cover the duration of the DVR window or the VOD file correspondingly. The player will add the thumbnail links to the progress bar at regular intervals. The duration of the interval between thumbnails is the whole duration of the DVR window or the VOD file divided by this value.
If you specify a big number, then the player will use additional resources which may make the player or the browser stuck. Decreasing this parameter allows to limit the number of thumbnails to play and thus to reduce the player resources usage.
This option requires the parameters thumbnails enabled=ondemand
and size
(thumbnail size) included in the stream or VOD location settings. For example, thumbnails enabled=ondemand size=320x240;
. You can specify multiple sizes separated by spaces, for example, size=320x250 size=640x480
. In this case, several thumbnails tracks will be included into the playlist. Each thumbnail in the playlist will be resized proportionally to fit the specified size.
For more information, please refer to Streaming API schema.