ApsaraVideo Live allows you to capture real-time snapshots during the playback of a live stream. This topic describes the snapshot feature of ApsaraVideo Live.
Prerequisites
Object Storage Service (OSS) is activated. An OSS bucket is created and used to store the snapshots that are captured during living streaming. For more information, see Activate OSS and Add media buckets.
The stream is re-ingested after a snapshot template is added. The template does not apply to ongoing live streams.
Snapshot rules
Snapshot rules for live streams are configured based on the
AppName
parameter of ingested streams. You can configure a snapshot rule for all ingested streams of a specific application. If theAppName
parameter is set to an asterisk (*), the snapshot rule applies to all ingested streams under the specified domain name. The value of theAppName
parameter for a recording rule must be the same as theAppName
parameter that is specified for the ingested stream.When you configure the snapshot feature, you can configure the ObjectName parameter to capture snapshots in overwrite mode or real-time mode.
In overwrite mode, the latest snapshot overwrites the existing snapshot.
In real-time mode, the latest snapshot is stored together with existing snapshots. All of the snapshots are stored in sequence and marked with ordinal numbers from 1 to n.
Live stream snapshots can be generated only in the JPG format.
When you use the API or SDKs to configure the snapshot feature, you must specify either the
OverwriteOssObject
orSequenceOssObject
parameter. No default values are specified for these parameters.
Use the snapshot feature
Configure the snapshot feature
You can configure the snapshot feature of ApsaraVideo Live by using one of the following methods:
Configure the snapshot feature in the ApsaraVideo Live console. For more information, see Configure snapshots.
Use the API or SDKs to configure the snapshot feature. You can use the API or SDKs to perform the following operations:
The following code provides an example on how to use the server SDK for Java to add a snapshot configuration:
AddLiveAppSnapshotConfigRequest addLiveAppSnapshotConfigRequest = new AddLiveAppSnapshotConfigRequest(); addLiveAppSnapshotConfigRequest.setDomainName("<DomainName>"); addLiveAppSnapshotConfigRequest.setAppName("<AppName>"); addLiveAppSnapshotConfigRequest.setTimeInterval(5); addLiveAppSnapshotConfigRequest.setOssEndpoint("<Endpoint>"); addLiveAppSnapshotConfigRequest.setOssBucket("<BucketName>"); addLiveAppSnapshotConfigRequest.setOverwriteOssObject("{AppName}/{StreamName}.jpg"); try { AddLiveAppSnapshotConfigResponse addLiveAppSnapshotConfigResponse = client.getAcsResponse(addLiveAppSnapshotConfigRequest); System.out.println(addLiveAppSnapshotConfigResponse.getRequestId()); // todo something. } catch (ServerException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientException e) { // TODO Auto-generated catch block e.printStackTrace(); }
NoteFor more information about the server SDK for Java, see Use the server SDK for Java.
Manage snapshots
After you configure the snapshot feature, snapshots are captured for newly ingested streams. You can view the snapshots by using one of the following methods:
View the snapshots in the ApsaraVideo Live console or OSS console. The snapshots are stored in an OSS bucket. You can manage the snapshots in the OSS bucket. For more information, see Manage snapshots.
NoteYou can delete snapshots only in the OSS console.
Use the API or SDKs to query the snapshots. For more information, see DescribeLiveStreamSnapshotInfo.