头像视频合成后,上传,查看
This commit is contained in:
@@ -51,6 +51,16 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
|
||||
// 使用BeanUtils复制相同名称的属性
|
||||
BeanUtils.copyProperties(request, synthesisLog);
|
||||
|
||||
// 设置视频名称(如果请求中有提供)
|
||||
if (request.getVideoName() != null && !request.getVideoName().trim().isEmpty()) {
|
||||
synthesisLog.setVideoName(request.getVideoName());
|
||||
log.info("设置视频名称: {}", request.getVideoName());
|
||||
} else {
|
||||
// 如果没有提供视频名称,使用默认名称
|
||||
synthesisLog.setVideoName("视频合成_" + requestId.substring(0, 8));
|
||||
log.info("使用默认视频名称: {}", synthesisLog.getVideoName());
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("开始视频合成,请求ID: {}, 图片URL: {}, 音频URL: {}",
|
||||
@@ -98,6 +108,16 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
synthesisLog.setTaskStatus("PENDING");
|
||||
synthesisLog.setSuccess(true);
|
||||
|
||||
// 生成临时访问URL(7天有效期)
|
||||
try {
|
||||
String tempUrl = generateTempVideoUrl(synthesisLog.getVideoName(), requestId);
|
||||
synthesisLog.setVideoTempUrl(tempUrl);
|
||||
log.info("生成临时访问URL: {}", tempUrl);
|
||||
} catch (Exception e) {
|
||||
log.warn("生成临时访问URL失败: {}", e.getMessage());
|
||||
// 临时URL生成失败不影响主流程
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("解析API响应JSON失败: {}", e.getMessage(), e);
|
||||
synthesisLog.setErrorMessage("解析API响应失败: " + e.getMessage());
|
||||
@@ -169,4 +189,28 @@ public class VideoSynthesisServiceImpl implements IVideoSynthesisService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成临时视频访问URL
|
||||
*
|
||||
* @param videoName 视频名称
|
||||
* @param requestId 请求ID
|
||||
* @return 临时访问URL
|
||||
*/
|
||||
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;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("生成临时视频URL失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user