视频直播的截图功能

microsoft 365下载 时间: 2025-09-04 05:33:34 作者: admin 查阅次数: 6281 公众评价: 289
视频直播的截图功能

Java// This file is auto-generated, don't edit it. Thanks.

package demo;

import com.aliyun.auth.credentials.Credential;

import com.aliyun.auth.credentials.provider.StaticCredentialProvider;

import com.aliyun.core.http.HttpClient;

import com.aliyun.core.http.HttpMethod;

import com.aliyun.core.http.ProxyOptions;

import com.aliyun.httpcomponent.httpclient.ApacheAsyncHttpClientBuilder;

import com.aliyun.sdk.service.live20161101.models.*;

import com.aliyun.sdk.service.live20161101.*;

import com.google.gson.Gson;

import darabonba.core.RequestConfiguration;

import darabonba.core.client.ClientOverrideConfiguration;

import darabonba.core.utils.CommonUtil;

import darabonba.core.TeaPair;

//import javax.net.ssl.KeyManager;

//import javax.net.ssl.X509TrustManager;

import java.net.InetSocketAddress;

import java.time.Duration;

import java.util.*;

import java.util.concurrent.CompletableFuture;

import java.io.*;

public class DeleteSnapshotFiles {

public static void main(String[] args) throws Exception {

// HttpClient Configuration

/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()

.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds

.responseTimeout(Duration.ofSeconds(10)) // Set the response timeout time, the default is 20 seconds

.maxConnections(128) // Set the connection pool size

.maxIdleTimeOut(Duration.ofSeconds(50)) // Set the connection pool timeout, the default is 30 seconds

// Configure the proxy

.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("", 9001))

.setCredentials("", ""))

// If it is an https connection, you need to configure the certificate, or ignore the certificate(.ignoreSSL(true))

.x509TrustManagers(new X509TrustManager[]{})

.keyManagers(new KeyManager[]{})

.ignoreSSL(false)

.build();*/

// Configure Credentials authentication information, including ak, secret, token

StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()

// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.

.accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))

.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))

//.securityToken(System.getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) // use STS token

.build());

// Configure the Client

AsyncClient client = AsyncClient.builder()

.region("") // Region ID

//.httpClient(httpClient) // Use the configured HttpClient, otherwise use the default HttpClient (Apache HttpClient)

.credentialsProvider(provider)

//.serviceConfiguration(Configuration.create()) // Service-level configuration

// Client-level configuration rewrite, can set Endpoint, Http request parameters, etc.

.overrideConfiguration(

ClientOverrideConfiguration.create()

// Endpoint 请参考 https://api.aliyun.com/product/live

.setEndpointOverride("live.aliyuncs.com")

//.setConnectTimeout(Duration.ofSeconds(30))

)

.build();

// Parameter settings for API request

DeleteSnapshotFilesRequest deleteSnapshotFilesRequest = DeleteSnapshotFilesRequest.builder()

.regionId("")

.domainName("")

.appName("")

.streamName("")

.removeFile(true)

// Request-level configuration rewrite, can set Http request parameters, etc.

// .requestConfiguration(RequestConfiguration.create().setHttpHeaders(new HttpHeaders()))

.build();

// Asynchronously get the return value of the API request

CompletableFuture response = client.deleteSnapshotFiles(deleteSnapshotFilesRequest);

// Synchronously get the return value of the API request

DeleteSnapshotFilesResponse resp = response.get();

System.out.println(new Gson().toJson(resp));

// Asynchronous processing of return values

/*response.thenAccept(resp -> {

System.out.println(new Gson().toJson(resp));

}).exceptionally(throwable -> { // Handling exceptions

System.out.println(throwable.getMessage());

return null;

});*/

// Finally, close the client

client.close();

}

}重要 目前只支持删除一年内的截图文件。

截图文件时间戳可通过查询截图文件获取。详情可参见查看截图文件。

对于覆盖截图的截图文件,目前只能在OSS中进行删除,具体操作可参见OSS删除文件。

更多删除直播截图文件接口说明,请参见DeleteSnapshotFiles。

以上示例实现了对截图文件的删除(同时删除了储存在OSS中的文件)。

您可以为截图功能设置回调事件,获取回调参数将截图信息保存至您自己的业务系统(同时储存时间戳),在需要删除文件时,您就可以根据您系统的策略(如通过定时任务每天定时删除N个月以前的截图文件)查询出截图文件时间戳对截图文件进行删除。若想了解截图回调,可参见直播截图回调开发指南。

关联

链接