头像视频合成

This commit is contained in:
spllzh
2025-10-08 08:02:21 +08:00
parent 76dedb657a
commit 45d061bad7
28 changed files with 689 additions and 13 deletions

View File

@@ -100,6 +100,9 @@ public class DifyWorkflowResponseDto {

View File

@@ -5,6 +5,8 @@ import lombok.Data;
import jakarta.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* 视频合成请求DTO
@@ -17,11 +19,11 @@ import java.math.BigDecimal;
public class VideoSynthesisRequestDto {
@NotBlank(message = "图片URL不能为空")
@Schema(description = "图片URL", required = true, example = "https://example.com/image.jpg")
@Schema(description = "图片URL", required = true)
private String imageUrl;
@NotBlank(message = "音频URL不能为空")
@Schema(description = "音频URL", required = true, example = "https://example.com/audio.wav")
@Schema(description = "音频URL", required = true)
private String audioUrl;
@Schema(description = "使用的模型", example = "liveportrait")
@@ -30,7 +32,7 @@ public class VideoSynthesisRequestDto {
@Schema(description = "图片ID", example = "img-12345")
private String imageId;
@Schema(description = "音频ID", example = "audio-67890")
@Schema(description = "音频ID", example ="audio-67890")
private String audioId;
@Schema(description = "归属人姓名", example = "张三")
@@ -59,4 +61,47 @@ public class VideoSynthesisRequestDto {
@Schema(description = "头部动作强度", example = "0.7")
private BigDecimal headMoveStrength = new BigDecimal("0.7");
@Schema(description = "输入数据", example = "{\"image_url\": \"http://xxx/1.jpg\", \"audio_url\": \"http://xxx/1.wav\"}")
private Map<String, String> input;
@Schema(description = "参数配置", example = "{\"template_id\": \"normal\", \"eye_move_freq\": 0.5, \"video_fps\": 30, \"mouth_move_strength\": 1, \"paste_back\": true, \"head_move_strength\": 0.7}")
private Map<String, Object> parameters;
/**
* 构建参数方法
* 用于构建 input 和 parameters 属性
*/
public void buildParam() {
// 构建 input 属性
this.input = new HashMap<>();
if (this.imageUrl != null) {
this.input.put("image_url", this.imageUrl);
}
if (this.audioUrl != null) {
this.input.put("audio_url", this.audioUrl);
}
// 构建 parameters 属性
this.parameters = new HashMap<>();
if (this.templateId != null) {
this.parameters.put("template_id", this.templateId);
}
if (this.eyeMoveFreq != null) {
this.parameters.put("eye_move_freq", this.eyeMoveFreq);
}
if (this.videoFps != null) {
this.parameters.put("video_fps", this.videoFps);
}
if (this.mouthMoveStrength != null) {
this.parameters.put("mouth_move_strength", this.mouthMoveStrength);
}
if (this.pasteBack != null) {
this.parameters.put("paste_back", this.pasteBack);
}
if (this.headMoveStrength != null) {
this.parameters.put("head_move_strength", this.headMoveStrength);
}
}
}