|
|
@@ -4163,6 +4163,8 @@ class AnimeService
|
|
|
$tail_frame_url = getProp($data, 'tail_frame_url');
|
|
|
$generate_audio = getProp($data, 'generate_audio', 1);
|
|
|
$video_duration = getProp($data, 'video_duration');
|
|
|
+ $video_resolution = getProp($data, 'video_resolution');
|
|
|
+ $ratio = getProp($data, 'ratio');
|
|
|
$products = getProp($data, 'products', []);
|
|
|
$reference_images = array_unique(getProp($data, 'reference_images', []));
|
|
|
if (!is_array($reference_images) || !is_array($products)) {
|
|
|
@@ -4183,8 +4185,8 @@ class AnimeService
|
|
|
|
|
|
$episode_id = getProp($act, 'episode_id');
|
|
|
$episode = DB::table('mp_anime_episodes')->where('id', $episode_id)->first();
|
|
|
- $ratio = '9:16';
|
|
|
- if (!$episode) $ratio = getProp($episode, 'ratio', '9:16');
|
|
|
+ if (!$ratio) $ratio = getProp($episode, 'ratio', '9:16');
|
|
|
+ if (!$video_resolution) $video_resolution = getProp($episode, 'video_resolution', '720p');
|
|
|
|
|
|
// 将资产中新出现的资产放到extra_products中
|
|
|
// 满足以下要求: 遍历传入的$products,将product_name与$episode中的roles和scenes做比对,如果不在其中,则与$episode中的extra_products做比对,如果有同名的则覆盖,没有则新增后存入$episode中的extra_products字段中
|
|
|
@@ -4273,7 +4275,7 @@ class AnimeService
|
|
|
'alias_act_id' => $act_id,
|
|
|
'prompt' => trim($fullPrompt),
|
|
|
'video_duration' => $videoDuration,
|
|
|
- 'video_resolution' => '720P',
|
|
|
+ 'video_resolution' => $video_resolution,
|
|
|
'seed' => -1,
|
|
|
'ratio' => $ratio,
|
|
|
'generate_audio' => (int)$current_generate_audio === 0 ? false : true,
|
|
|
@@ -4891,6 +4893,57 @@ class AnimeService
|
|
|
$prompt = getProp($data, 'prompt');
|
|
|
$episode_id = getProp($data, 'episode_id');
|
|
|
$ref_img_urls = getProp($data, 'ref_img_urls');
|
|
|
+ $ratio = getProp($data, 'ratio', '9:16');
|
|
|
+ $resolution = getProp($data, 'resolution', '2k');
|
|
|
+
|
|
|
+ // 定义分辨率和宽高比对应的尺寸映射表
|
|
|
+ $sizeMap = [
|
|
|
+ '2k' => [
|
|
|
+ '1:1' => ['width' => 2048, 'height' => 2048],
|
|
|
+ '4:3' => ['width' => 2304, 'height' => 1728],
|
|
|
+ '3:4' => ['width' => 1728, 'height' => 2304],
|
|
|
+ '16:9' => ['width' => 2848, 'height' => 1600],
|
|
|
+ '9:16' => ['width' => 1600, 'height' => 2848],
|
|
|
+ '3:2' => ['width' => 2496, 'height' => 1664],
|
|
|
+ '2:3' => ['width' => 1664, 'height' => 2496],
|
|
|
+ '21:9' => ['width' => 3136, 'height' => 1344],
|
|
|
+ ],
|
|
|
+ '3k' => [
|
|
|
+ '1:1' => ['width' => 3072, 'height' => 3072],
|
|
|
+ '4:3' => ['width' => 3456, 'height' => 2592],
|
|
|
+ '3:4' => ['width' => 2592, 'height' => 3456],
|
|
|
+ '16:9' => ['width' => 4096, 'height' => 2304],
|
|
|
+ '9:16' => ['width' => 2304, 'height' => 4096],
|
|
|
+ '2:3' => ['width' => 2496, 'height' => 3744],
|
|
|
+ '3:2' => ['width' => 3744, 'height' => 2496],
|
|
|
+ '21:9' => ['width' => 4704, 'height' => 2016],
|
|
|
+ ],
|
|
|
+ '4k' => [
|
|
|
+ '1:1' => ['width' => 4096, 'height' => 4096],
|
|
|
+ '3:4' => ['width' => 3520, 'height' => 4704],
|
|
|
+ '4:3' => ['width' => 4704, 'height' => 3520],
|
|
|
+ '16:9' => ['width' => 5504, 'height' => 3040],
|
|
|
+ '9:16' => ['width' => 3040, 'height' => 5504],
|
|
|
+ '2:3' => ['width' => 3328, 'height' => 4992],
|
|
|
+ '3:2' => ['width' => 4992, 'height' => 3328],
|
|
|
+ '21:9' => ['width' => 6240, 'height' => 2656],
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ $resolution = strtolower($resolution);
|
|
|
+ if (!isset($sizeMap[$resolution])) {
|
|
|
+ Utils::throwError('20003:分辨率参数错误,仅支持 2k、3k、4k');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isset($sizeMap[$resolution][$ratio])) {
|
|
|
+ Utils::throwError('20003:宽高比参数错误,该分辨率下不支持 ' . $ratio . ' 比例');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据 ratio 和 resolution 确定宽高
|
|
|
+ $width = $sizeMap[$resolution][$ratio]['width'];
|
|
|
+ $height = $sizeMap[$resolution][$ratio]['height'];
|
|
|
+
|
|
|
if (!is_array($ref_img_urls) && !empty($ref_img_urls)) {
|
|
|
if (is_json($ref_img_urls)) {
|
|
|
$ref_img_urls = json_decode($ref_img_urls, true);
|
|
|
@@ -4934,8 +4987,8 @@ class AnimeService
|
|
|
'prompt' => $prompt,
|
|
|
'model' => $model,
|
|
|
'ref_img_urls' => '',
|
|
|
- 'width' => 1600,
|
|
|
- 'height' => 2848
|
|
|
+ 'width' => $width,
|
|
|
+ 'height' => $height
|
|
|
];
|
|
|
if ($ref_img_urls) $params['ref_img_urls'] = is_array($ref_img_urls) ? $ref_img_urls : [$ref_img_urls];
|
|
|
|
|
|
@@ -6368,6 +6421,34 @@ class AnimeService
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ public function saveActVideoGenerateParams($data) {
|
|
|
+ $episode_id = getProp($data, 'episode_id');
|
|
|
+ $model = getProp($data, 'video_model');
|
|
|
+ if (!in_array($model, ['zhizhen-20', 'zhizhen-20-fas', 'zhizhen-20-mini'])) {
|
|
|
+ Utils::throwError('20003:该模型不可用');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$model) {
|
|
|
+ // 使用默认模型
|
|
|
+ $model = 'zhizhen-20-mini';
|
|
|
+ }
|
|
|
+ // 验证模型是否在可用模型表中
|
|
|
+ if (!DB::table('mp_video_models')->where('model', $model)->where('is_enabled', 1)->exists()) {
|
|
|
+ Utils::throwError('20003:该模型已不可用,请更换!');
|
|
|
+ }
|
|
|
+ $video_resolution = getProp($data, 'video_resolution', '720p');
|
|
|
+ $ratio = getProp($data, 'ratio');
|
|
|
+ if (!$ratio) $ratio = '9:16';
|
|
|
+
|
|
|
+ return DB::table('mp_anime_episodes')->where('id', $episode_id)->update([
|
|
|
+ 'video_model' => $model,
|
|
|
+ 'video_resolution' => $video_resolution,
|
|
|
+ 'ratio' => $ratio,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function confirmActs($data) {
|
|
|
$episode_id = getProp($data, 'episode_id');
|
|
|
|