ApsaraVideo Live allows you to take 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 as a media bucket to store the snapshots that are taken during living streaming.
  • A new stream is ingested after a snapshot template is configured. The configured 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 the AppName parameter is set to an asterisk (*), the snapshot rule applies to all ingested streams of the specified live domain. The value of the AppName parameter of an ingested stream must be the same as that in the snapshot configuration.
  • When you configure the snapshot feature, you can set the ObjectName parameter to take 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.
    • You can generate live streaming snapshots only in the JPG format.
  • When you use the API or SDKs to configure the snapshot feature, set one of the OverwriteOssObject or SequenceOssObject parameters. No default value is specified for the two 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 snapshot settings.

    • 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 SDK for Java to add a snapshot configuration:
          IClientProfile profile = DefaultProfile.getProfile("cn-shanghai","<AccessKeyId>", "<AccessKeySecret>");
          IAcsClient client = new DefaultAcsClient(profile);
          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();
          }                  
  • Manage snapshots

    After you configure the snapshot feature, snapshots are taken for newly ingested streams. You can view the snapshots by using one of the following methods: