动态头像-mp4-提交转码异步任务
This commit is contained in:
@@ -977,4 +977,8 @@ public class MyApiService {
|
||||
Date cycleDateTime = StringUtils.isNotBlank(cycleDate) ? DateTimeUtil.convertStrToDate(cycleDate, DateTimeUtil.DEFAULT_DATE_PATTERN): null;
|
||||
guildCrystalSettlementService.settlement(PartitionEnum.TURKEY.getId(), cycleDateTime, waitSecond);
|
||||
}
|
||||
|
||||
public void mp4TransferGif(String url) {
|
||||
SpringContextHolder.getBean(UploadAvatarService.class).reviewAvatar(null, url, null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
@@ -385,4 +385,14 @@ public class MyApiController {
|
||||
myApiService.guildCrystalSettlement(cycleDate, waitSecond);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/mp4TransferGif")
|
||||
public BusiResult<Void> mp4TransferGif(Long roomId) {
|
||||
if (null == roomId || !roomId.equals(603L)) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
String url = "https://image.molistar.xyz/64854f73-ea1b-426f-8230-34de49571b8a.mp4";
|
||||
myApiService.mp4TransferGif(url);
|
||||
return BusiResult.success();
|
||||
}
|
||||
}
|
||||
|
@@ -32,4 +32,6 @@ public class TencentCosConfig {
|
||||
|
||||
private Boolean accelerate = false;
|
||||
|
||||
private String gifJobTemplateId;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,67 @@
|
||||
package com.accompany.business.service;
|
||||
|
||||
import com.accompany.common.config.TencentCosConfig;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.UUIDUtil;
|
||||
import com.accompany.core.base.SpringContextHolder;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.model.ciModel.job.MediaJobResponse;
|
||||
import com.qcloud.cos.model.ciModel.job.MediaJobsRequest;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TencentDataUniverseService {
|
||||
|
||||
@Autowired
|
||||
private TencentCosConfig tencentCosConfig;
|
||||
@Autowired
|
||||
private COSClient client;
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
|
||||
@SneakyThrows
|
||||
@Async
|
||||
public void transfer2Gif(Long uid, String avatar, String redisKey, Long price, String ip, String deviceId) {
|
||||
|
||||
URL url = new URL(avatar);
|
||||
String inputPath = url.getPath();
|
||||
String outputPath = inputPath.replace(".mp4", ".gif");
|
||||
String outputAvatar = url.getHost() + outputPath;
|
||||
|
||||
//1.创建任务请求对象
|
||||
MediaJobsRequest request = new MediaJobsRequest();
|
||||
//2.添加请求参数 参数详情请见 API 接口文档
|
||||
request.setBucketName(tencentCosConfig.getBucket());
|
||||
request.setTag("Animation");
|
||||
request.getInput().setObject(inputPath);
|
||||
request.getOperation().setTemplateId(tencentCosConfig.getGifJobTemplateId());
|
||||
request.getOperation().getOutput().setBucket(tencentCosConfig.getBucket());
|
||||
request.getOperation().getOutput().setRegion(tencentCosConfig.getRegion());
|
||||
request.getOperation().getOutput().setObject(outputPath);
|
||||
//3.调用接口,获取任务响应对象
|
||||
MediaJobResponse response = client.createMediaJobs(request);
|
||||
log.info("tencent mp4转码gif 任务提交结果: {}", JSON.toJSONString(response));
|
||||
|
||||
//正式环境等回调
|
||||
if (!envComponent.getDevOrNativeEnv()){
|
||||
return;
|
||||
}
|
||||
|
||||
String taskId = UUIDUtil.get();
|
||||
SpringContextHolder.getBean(UploadAvatarService.class).cacheReviewAvatar(redisKey, String.valueOf(uid), outputAvatar, price);
|
||||
SpringContextHolder.getBean(JedisService.class).hset(RedisKey.user_avatar_review_task.getKey(), taskId, String.valueOf(uid));
|
||||
|
||||
SpringContextHolder.getBean(UploadAvatarService.class).updateAvatar(outputAvatar, uid, redisKey, taskId);
|
||||
}
|
||||
|
||||
}
|
@@ -74,7 +74,7 @@
|
||||
<sharding-jdbc.version>5.5.2</sharding-jdbc.version>
|
||||
<commons-lang.version>2.6</commons-lang.version>
|
||||
<tencentcloud-sdk-java.version>3.1.781</tencentcloud-sdk-java.version>
|
||||
<tencentcloud-cos-sdk-java.version>5.6.179</tencentcloud-cos-sdk-java.version>
|
||||
<tencentcloud-cos-sdk-java.version>5.6.253</tencentcloud-cos-sdk-java.version>
|
||||
<tencentcloud-cos-sts-sdk-java.version>3.1.1</tencentcloud-cos-sts-sdk-java.version>
|
||||
<rocketmq-spring-boot.version>2.3.3</rocketmq-spring-boot.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
|
Reference in New Issue
Block a user