Using HTTP Live Streaming (HLS) from Alta Video
Last modified: Tuesday May 21, 2024.
HTTP Live Streaming (HLS) is a commonly-used method for streaming live video, recorded video, or bookmarked Saved clips to a web page, webapp, or other viewer that uses a suitable HLS Javascript library. You can also view HLS streams on media players such as VLC, ffmpeg/ffplay, or GStreamer.
The HLS protocol is built on top of HTTP. The client sends HTTP requests to download playlists and media chunks from Alta Video. Each chunk contains about one second of video and audio from the stream. This means that the HLS client sends two requests per second, one to download the updated media playlist, and the other to request the next media chunk. The Alta Video HLS service buffers six seconds of media before responding to the initial client request. This leads to a short delay in serving the video when the stream is first loaded.
This provides a method for you to take the live, recorded
The HLS service takes care of requesting the streams using the Alta Video Cloud APIs and handles the media path negotiations to the source of the video stream.
Item | Description |
---|---|
The client application makes an HLS request using the URL to the Alta Video HLS service. | |
The HLS service uses the credentials from that HLS request to authenticate with the Alta Video Cloud deployment. | |
After successfully authenticating, the HLS service performs the API requests to the Alta Video Cloud deployment to set up the required stream. This includes information about the camera to stream, whether it is a live stream, playback of recorded video, or a bookmarked saved clip, the time to start the playback, as well as other parameters. | |
The stream negotiation takes place, with the client end being the HLS service. Media may flow directly from the device to the HLS service, or via a TURN server. | |
Media flows from the requested device to the HLS service. The HLS service then sends the video data to the client application using HTTPS. |
Use the Alta Video Cloud API to collect the information needed to form the URL needed to request and stream the video from an Alta Video Cloud deployment to your application.
URL structure
For viewing live video and playback, the URL is in the format: https://<deploymentname>.stream.<region>.alta.avigilon.com/<streamMode>?deviceId=<deviceId>&<parameters>
For example, to view live video from https://example.us1.alta.avigilon.com, create:
https://example.stream.us1.alta.avigilon.com/hls/streams/index?deviceId=<GUID>
&<parameters>
To view video playback from https://example.us1.alta.avigilon.com:
https://example.stream.us1.alta.avigilon.com/hls/playback/index?deviceId=<GUID>&<parameters>
For bookmarked Saved clips, the URL is in the format:
To view a bookmark from https://example.us1.alta.avigilon.com:
https://example.stream.us1.alta.avigilon.com/hls/bookmark/<BookmarkToken>/index
Where:
- Only HTTPS streams, are allowed.
- <deployment> is the first part of the name of your Alta Video deployment. This is the information at the beginning of the URL you use at access your Alta Video Cloud deployment, or that you use to log into the Alta Video mobile app.
- <region> to keep the shortest routing of the video, use the region to which your deployment is associated. For example, us1 or eu1.
- <streamMode> is streams for viewing live video and playback to view historic video.
- <deviceId> is the GUID for the camera to stream.
- <BookmarkToken> is the token that identifies the bookmark of interest.
- <parameters> are the additional information needed for your chosen stream. For example:
- When streaming live video, you can optionally specify the height and width for the stream, for example, &height=360&width=720
- When playing back historic video, specify the time that the video should start, for example, &startTimestamp=2024-05-15T07:20:00.00Z
Timestamps should be entered using the UTC/GMT timezone.
- For bookmarks, you can specify the source from a multi-source device by using the pane=<n> parameter, where n is the number of the required source. This defaults to source 1 if not defined.
Currently, you cannot use HLS to view password-protected Saved clips.
- Authentication of the application user is done via the credentials supplied with the HLS request. The same credentials can be used for the HLS and other API requests.
You can take the URL you use to connect to your Alta Video deployment, and edit it by adding .stream between the deployment name and the region. You then need to add the <streamMode>, <deviceId>, and <parameters> for your chosen HLS stream.
You cannot use the username and password embedded within into the HLS URL when streaming to a website or webApp, as the command ignores credentials. You can embed username and password credentials into the URL if you are streaming to a non-web video player such as VLC.
Depending on the application receiving the stream, you might be able to embed the credentials for non-web video players. Edit the string to include <username>:<password>@ immediately before the deployment information, as follows: https://<username:password>@<deploymentname>.stream.<region>.alta.avigilon.com/hls/<streamMode>?deviceId=<deviceId>&<parameters>
The username and password is visible in plain text within the URL.
In addition, we recommend that you create a user with only the minimum permissions required to view your chosen stream.
When entering the email address used as the user name within the URL, replace the
Example: https://user%40example.com:<password>@<deploymentname>.stream.<region>.alta.avigilon.com/<streamMode>?deviceId=<deviceId>&<parameters>
Use the credentials for a configured Alta Video user that has the relevant permissions for the selected device.
When streaming to external websites or webapps, you need to whitelist the site using cross-origin resource sharing so that Alta Video can successfully stream to the site. See Configure cross-origin resource sharing in Alta Video
Required permissions
The authentication for HLS streams is sent in plain text. Because of this, we recommend you create a user account that has only the permissions required for the type of streaming you are planning. When using the HLS service, ensure that the Alta Video user account used with the HLS service has the relevant permissions:
- For streaming of live video — the Alta Video Cloud user account must include the
View live video general permission for the relevant device. - For playback of historic video — the Alta Video Cloud user account must include the
View historic video general permission for the relevant device.
All other permissions should be disabled, to prevent the user credentials being used to gain unauthorized access to your Alta Video deployment.
Also, ensure that the user account is added to a suitable User Group.