|
|
|
@ -43,6 +43,13 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
File imageFile = fileManageService.downloadFile(human.getImageFileId());
|
|
|
|
|
// 创建一个图片临时文件
|
|
|
|
|
log.info("提交文件生成,文件名:{}", FileUtil.getName(imageFile));
|
|
|
|
|
generateSilent(human, imageFile);
|
|
|
|
|
generateDynamic(human, imageFile);
|
|
|
|
|
|
|
|
|
|
humanService.updateById(human);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateSilent(Human human, File imageFile) throws Exception {
|
|
|
|
|
HumanGenerateDTO silentDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + silent, Map.of("image", imageFile));
|
|
|
|
@ -50,14 +57,6 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人静态视频异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + dynamic, Map.of("image", imageFile));
|
|
|
|
|
dynamicDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人动态视频异常");
|
|
|
|
|
}
|
|
|
|
|
// 保存静态视频
|
|
|
|
|
if (silentDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(silentDTO.getVideo())) {
|
|
|
|
@ -69,6 +68,18 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
human.setSilentTaskUid(silentDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateDynamic(Human human, File imageFile) throws Exception {
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + dynamic, Map.of("image", imageFile));
|
|
|
|
|
dynamicDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人动态视频异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dynamicDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(dynamicDTO.getVideo())) {
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
@ -76,9 +87,8 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
human.setDynamicVideoFileId(fileResource.getId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
human.setDynamicTaskUid(silentDTO.getUid());
|
|
|
|
|
human.setDynamicTaskUid(dynamicDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
humanService.updateById(human);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FileResource convertBase64ToFile(String prefixName, String imageFileName, String base64) throws Exception {
|
|
|
|
|