Get Preview MP4 from Archive with API
When Save Preview is enabled in the Storage settings, Alta saves short preview clips in MP4 format for the recorded archive. This article describes how to list the preview files of a channel and download them with curl.
Requirements
Section titled “Requirements”- The channel has a Storage assigned and the storage has Save Preview enabled.
- The channel uses H.264 or H.265 video.
- Requests go to the API Server (default port
8100), not to the OTT Server. Read more HTTP Server. - The API requires HTTP Basic authentication with a user of the Alta web interface. Read more Users.
Channel Path
Section titled “Channel Path”Both requests use the id parameter with the channel path in the format <channel_name>/<variant>, for example discovery/hd.
List Preview Files
Section titled “List Preview Files”URL:
GET /api/ott/channel/storage/preview?id=<channel_name>/<variant>or with the optional parameter:
GET /api/ott/channel/storage/preview?id=<channel_name>/<variant>&start=<time>- id: Channel path.
- start (optional): Unix timestamp. Returns files from this time onward.
Alta does not support the end parameter. To limit the result by the end time, filter the list on the client side.
Example:
curl -sS -u 'USER:PASSWORD' \ 'http://alta.example.com:8100/api/ott/channel/storage/preview?id=discovery/hd&start=1747485787'Response:
["1747485787.mp4", "1747485797.mp4", "1747485807.mp4"]The response is a JSON array of file names. The name of each file is the Unix timestamp of the segment start.
Download Preview File
Section titled “Download Preview File”URL:
GET /api/ott/channel/storage/preview?id=<channel_name>/<variant>&name=<file>- id: Channel path.
- name: File name from the list, for example
1747485787.mp4.
Example:
curl -sS -f -u 'USER:PASSWORD' \ -o preview.mp4 \ 'http://alta.example.com:8100/api/ott/channel/storage/preview?id=discovery/hd&name=1747485787.mp4'The response body is the MP4 file. Option -f makes curl fail on HTTP errors instead of saving the error page into the file.
Response Codes
Section titled “Response Codes”| Code | Description |
|---|---|
200 | Success |
404 | No preview files found for the channel or time range, or the file does not exist |
Troubleshooting
Section titled “Troubleshooting”Empty list or 404
Section titled “Empty list or 404”- Check that Save Preview is enabled in the storage and the channel is recording.
- Check the channel path. It must include the variant, for example
discovery/hd. - Remove the
startparameter or decrease its value. Preview files are available only for the archive duration of the storage.
Connection refused
Section titled “Connection refused”Check that you use the port of the API Server, not the OTT Server. Test the connection:
curl -v http://alta.example.com:8100/