头像视频合成支持动态模型
This commit is contained in:
@@ -6,6 +6,7 @@ import com.rj.dto.VideoSynthesisRequestDto;
|
||||
import com.rj.entity.VideoSynthesisLog;
|
||||
import com.rj.mapper.VideoSynthesisLogMapper;
|
||||
import com.rj.service.IVideoSynthesisService;
|
||||
import com.rj.utils.MinIOUrlGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 视频合成服务实现类
|
||||
@@ -33,6 +35,8 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
MinIOUrlGenerator minIOUrlGenerator ;
|
||||
|
||||
@Value("${dashscope.api.key}")
|
||||
private String apiKey;
|
||||
@@ -62,6 +66,18 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
log.info("使用默认视频名称: {}", synthesisLog.getVideoName());
|
||||
}
|
||||
|
||||
// 设置人脸区域坐标(如果请求中有提供)
|
||||
if (request.getFaceBbox() != null && !request.getFaceBbox().trim().isEmpty()) {
|
||||
synthesisLog.setFaceBbox(request.getFaceBbox());
|
||||
log.info("设置人脸区域坐标: {}", request.getFaceBbox());
|
||||
}
|
||||
|
||||
// 设置动态区域坐标(如果请求中有提供)
|
||||
if (request.getExtBbox() != null && !request.getExtBbox().trim().isEmpty()) {
|
||||
synthesisLog.setExtBbox(request.getExtBbox());
|
||||
log.info("设置动态区域坐标: {}", request.getExtBbox());
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("开始视频合成,请求ID: {}, 图片URL: {}, 音频URL: {}",
|
||||
requestId, request.getImageUrl(), request.getAudioUrl());
|
||||
@@ -110,6 +126,7 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
|
||||
// 生成临时访问URL(7天有效期)
|
||||
try {
|
||||
log.info("即将用音频名称: {}, 生成临时访问URL", synthesisLog.getVideoName());
|
||||
String tempUrl = generateTempVideoUrl(synthesisLog.getVideoName(), requestId);
|
||||
synthesisLog.setVideoTempUrl(tempUrl);
|
||||
log.info("生成临时访问URL: {}", tempUrl);
|
||||
@@ -199,14 +216,8 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
*/
|
||||
private String generateTempVideoUrl(String videoName, String requestId) {
|
||||
try {
|
||||
// 构建临时访问URL
|
||||
// 格式: https://your-domain.com/video/temp/{requestId}?name={videoName}
|
||||
String baseUrl = "https://your-domain.com"; // 这里应该从配置文件读取
|
||||
String encodedVideoName = java.net.URLEncoder.encode(videoName, "UTF-8");
|
||||
String tempUrl = String.format("%s/video/temp/%s?name=%s", baseUrl, requestId, encodedVideoName);
|
||||
|
||||
log.info("生成临时视频URL: 视频名称={}, 请求ID={}, URL={}", videoName, requestId, tempUrl);
|
||||
return tempUrl;
|
||||
|
||||
return minIOUrlGenerator.generateTempUrl(videoName, 7, TimeUnit.DAYS).getUrl();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("生成临时视频URL失败: {}", e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user