头像视频合成支持动态模型

This commit is contained in:
spllzh
2025-10-09 08:38:17 +08:00
parent e5cba62007
commit 6dff49fcc1
30 changed files with 376 additions and 36 deletions

View File

@@ -107,6 +107,10 @@ public class AudioStatisticsScheduler {

View File

@@ -7,6 +7,7 @@ import com.rj.config.AliyunConfig;
import com.rj.entity.VideoSynthesisLog;
import com.rj.mapper.VideoSynthesisLogMapper;
import com.rj.service.MinIOService;
import com.rj.utils.MinIOUrlGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
@@ -24,6 +25,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 视频合成任务状态检查定时器
@@ -48,6 +50,9 @@ public class VideoSynthesisStatusScheduler {
@Autowired
private MinIOService minIOService;
@Autowired
MinIOUrlGenerator urlGenerator;
/**
* 每5分钟执行一次任务状态检查
*/
@@ -169,7 +174,7 @@ public class VideoSynthesisStatusScheduler {
// 更新临时访问URL使用MinIO的预签名URL
try {
String tempUrl = generateTempVideoUrl(task.getVideoName(), task.getRequestId());
String tempUrl = generateTempVideoUrl("video_synthesis/"+task.getVideoName(), task.getRequestId());
task.setVideoTempUrl(tempUrl);
log.info("更新临时访问URL: {}", tempUrl);
} catch (Exception e) {
@@ -193,6 +198,24 @@ public class VideoSynthesisStatusScheduler {
}
}
// 解析人脸区域坐标
if (output.containsKey("face_bbox")) {
String faceBbox = output.getString("face_bbox");
if (faceBbox != null && !faceBbox.trim().isEmpty()) {
task.setFaceBbox(faceBbox);
log.info("更新人脸区域坐标: {}", faceBbox);
}
}
// 解析动态区域坐标
if (output.containsKey("ext_bbox")) {
String extBbox = output.getString("ext_bbox");
if (extBbox != null && !extBbox.trim().isEmpty()) {
task.setExtBbox(extBbox);
log.info("更新动态区域坐标: {}", extBbox);
}
}
// 保存到数据库
int updateResult = videoSynthesisLogMapper.updateById(task);
if (updateResult > 0) {
@@ -365,6 +388,7 @@ public class VideoSynthesisStatusScheduler {
}
}
/**
* 生成临时视频访问URL
*
@@ -374,14 +398,7 @@ public class VideoSynthesisStatusScheduler {
*/
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 urlGenerator.generateTempUrl(videoName,7, TimeUnit.DAYS).getUrl();
} catch (Exception e) {
log.error("生成临时视频URL失败: {}", e.getMessage(), e);