|
|
@@ -94,6 +94,8 @@ class AnimeService
|
|
|
'audio_duration' => getProp($segment, 'audio_duration', 0),
|
|
|
'video_url' => getProp($segment, 'video_url'),
|
|
|
'video_duration' => getProp($segment, 'video_duration', 0),
|
|
|
+ 'video_time_point_start' => getProp($segment, 'video_time_point_start', 0),
|
|
|
+ 'video_time_point_end' => getProp($segment, 'video_time_point_end', getProp($segment, 'video_duration', 0)),
|
|
|
'last_frame_url' => getProp($segment, 'last_frame_url'),
|
|
|
'current_type' => getProp($segment, 'current_type'),
|
|
|
];
|
|
|
@@ -332,84 +334,114 @@ class AnimeService
|
|
|
}
|
|
|
|
|
|
public function editAnime($data) {
|
|
|
- $script_arr =getProp($data, 'script', []);
|
|
|
- if (!$script_arr) Utils::throwError('20003:剧本内容不能为空');
|
|
|
- $start_episode_sequence = getProp($data, 'start_episode_sequence', 1);
|
|
|
$anime_id = getProp($data, 'anime_id');
|
|
|
- try {
|
|
|
- DB::beginTransaction();
|
|
|
- $table_data = [
|
|
|
- 'intro' => isset($script_arr['intro']) ? $script_arr['intro'] : '',
|
|
|
- 'highlights' => isset($script_arr['highlights']) ? $script_arr['highlights'] : '',
|
|
|
- 'role_relationship' => isset($script_arr['role_relationship']) ? $script_arr['role_relationship'] : '',
|
|
|
- 'core_contradiction' => isset($script_arr['core_contradiction']) ? $script_arr['core_contradiction'] : '',
|
|
|
- 'roles' => isset($script_arr['roles']) ? json_encode($script_arr['roles'], 256) : '',
|
|
|
- 'art_style' => isset($script_arr['art_style']) ? $script_arr['art_style'] : '',
|
|
|
- 'scenes' => isset($script_arr['scenes']) ? json_encode($script_arr['scenes'], 256) : '',
|
|
|
- 'status' => 3,
|
|
|
- 'start_episode_sequence' => $start_episode_sequence,
|
|
|
- 'end_episode_sequence' => $start_episode_sequence + count($script_arr['episodes']) - 1,
|
|
|
- 'episode_num' => count($script_arr['episodes']),
|
|
|
- 'updated_at' => date('Y-m-d H:i:s')
|
|
|
- ];
|
|
|
+ $anime_name = trim(getProp($data, 'anime_name'));
|
|
|
|
|
|
- // 保存剧本内容
|
|
|
- if (!empty($anime_id)) {
|
|
|
- $boolen = DB::table('mp_animes')->where('id', $anime_id)->update($table_data);
|
|
|
- if (!$boolen) {
|
|
|
- dLog('anime')->info('对话保存失败', $table_data);
|
|
|
- Utils::throwError('20003:对话保存失败');
|
|
|
- }
|
|
|
- }else {
|
|
|
- $table['created_at'] = $table_data['updated_at'];
|
|
|
- $anime_id = DB::table('mp_animes')->insertGetId($table_data);
|
|
|
- if (!$anime_id) {
|
|
|
- dLog('anime')->info('对话保存失败', $table_data);
|
|
|
- Utils::throwError('20003:对话保存失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 保存分集内容
|
|
|
- // 删除历史分集内容
|
|
|
- $boolen1 = DB::table('mp_anime_episodes')->where('anime_id', $anime_id)->delete();
|
|
|
-
|
|
|
- $episodes = [];
|
|
|
- $sequence = 1;
|
|
|
- foreach ($script_arr['episodes'] as $episode) {
|
|
|
- $segment_number = 1;
|
|
|
- foreach($episode['segments'] as $segment) {
|
|
|
- $episodes[] = [
|
|
|
- 'anime_id' => $anime_id,
|
|
|
- 'episode_number' => $episode['episode_number'],
|
|
|
- 'title' => $episode['title'],
|
|
|
- // 'content' => $episode['content'],
|
|
|
- 'content' => '',
|
|
|
- 'segment_number' => $segment_number,
|
|
|
- 'segment_content' => $segment['segment_content'],
|
|
|
- 'sequence' => $sequence,
|
|
|
- 'created_at' => date('Y-m-d H:i:s'),
|
|
|
- 'updated_at' => date('Y-m-d H:i:s')
|
|
|
- ];
|
|
|
- $sequence++;
|
|
|
- $segment_number++;
|
|
|
- }
|
|
|
+ // 确认对话名称唯一性
|
|
|
+ if ($id = DB::table('mp_animes')->where('anime_name', $anime_name)->value('id')) {
|
|
|
+ if ($id != $anime_id) $anime_name = $anime_name . '_' . date('YmdHis');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$anime_id || !$anime_name) {
|
|
|
+ Utils::throwError('20003:参数异常');
|
|
|
+ }
|
|
|
+
|
|
|
+ return DB::table('mp_animes')->where('id', $anime_id)->update([
|
|
|
+ 'anime_name' => $anime_name,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // $script_arr =getProp($data, 'script', []);
|
|
|
+ // if (!$script_arr) Utils::throwError('20003:剧本内容不能为空');
|
|
|
+ // $start_episode_sequence = getProp($data, 'start_episode_sequence', 1);
|
|
|
+ // $anime_id = getProp($data, 'anime_id');
|
|
|
+ // try {
|
|
|
+ // DB::beginTransaction();
|
|
|
+ // $table_data = [
|
|
|
+ // 'intro' => isset($script_arr['intro']) ? $script_arr['intro'] : '',
|
|
|
+ // 'highlights' => isset($script_arr['highlights']) ? $script_arr['highlights'] : '',
|
|
|
+ // 'role_relationship' => isset($script_arr['role_relationship']) ? $script_arr['role_relationship'] : '',
|
|
|
+ // 'core_contradiction' => isset($script_arr['core_contradiction']) ? $script_arr['core_contradiction'] : '',
|
|
|
+ // 'roles' => isset($script_arr['roles']) ? json_encode($script_arr['roles'], 256) : '',
|
|
|
+ // 'art_style' => isset($script_arr['art_style']) ? $script_arr['art_style'] : '',
|
|
|
+ // 'scenes' => isset($script_arr['scenes']) ? json_encode($script_arr['scenes'], 256) : '',
|
|
|
+ // 'status' => 3,
|
|
|
+ // 'start_episode_sequence' => $start_episode_sequence,
|
|
|
+ // 'end_episode_sequence' => $start_episode_sequence + count($script_arr['episodes']) - 1,
|
|
|
+ // 'episode_num' => count($script_arr['episodes']),
|
|
|
+ // 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ // ];
|
|
|
+
|
|
|
+ // // 保存剧本内容
|
|
|
+ // if (!empty($anime_id)) {
|
|
|
+ // $boolen = DB::table('mp_animes')->where('id', $anime_id)->update($table_data);
|
|
|
+ // if (!$boolen) {
|
|
|
+ // dLog('anime')->info('对话保存失败', $table_data);
|
|
|
+ // Utils::throwError('20003:对话保存失败');
|
|
|
+ // }
|
|
|
+ // }else {
|
|
|
+ // $table['created_at'] = $table_data['updated_at'];
|
|
|
+ // $anime_id = DB::table('mp_animes')->insertGetId($table_data);
|
|
|
+ // if (!$anime_id) {
|
|
|
+ // dLog('anime')->info('对话保存失败', $table_data);
|
|
|
+ // Utils::throwError('20003:对话保存失败');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // // 保存分集内容
|
|
|
+ // // 删除历史分集内容
|
|
|
+ // $boolen1 = DB::table('mp_anime_episodes')->where('anime_id', $anime_id)->delete();
|
|
|
+
|
|
|
+ // $episodes = [];
|
|
|
+ // $sequence = 1;
|
|
|
+ // foreach ($script_arr['episodes'] as $episode) {
|
|
|
+ // $segment_number = 1;
|
|
|
+ // foreach($episode['segments'] as $segment) {
|
|
|
+ // $episodes[] = [
|
|
|
+ // 'anime_id' => $anime_id,
|
|
|
+ // 'episode_number' => $episode['episode_number'],
|
|
|
+ // 'title' => $episode['title'],
|
|
|
+ // // 'content' => $episode['content'],
|
|
|
+ // 'content' => '',
|
|
|
+ // 'segment_number' => $segment_number,
|
|
|
+ // 'segment_content' => $segment['segment_content'],
|
|
|
+ // 'sequence' => $sequence,
|
|
|
+ // 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ // 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ // ];
|
|
|
+ // $sequence++;
|
|
|
+ // $segment_number++;
|
|
|
+ // }
|
|
|
|
|
|
- }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // $boolen2 = DB::table('mp_anime_episodes')->insert($episodes);
|
|
|
+ // if (!$boolen2) {
|
|
|
+ // dLog('deepseek')->info('分集内容保存失败', $episodes);
|
|
|
+ // logDB('deepseek', 'error', '分集内容保存失败', ['episodes_count' => count($episodes)]);
|
|
|
+ // Utils::throwError('20003:分集内容保存失败');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // } catch (\Exception $e) {
|
|
|
+ // DB::rollBack();
|
|
|
+ // Utils::throwError('20003:'.$e->getMessage());
|
|
|
+ // }
|
|
|
+ // DB::commit();
|
|
|
+ // return true;
|
|
|
+ }
|
|
|
|
|
|
- $boolen2 = DB::table('mp_anime_episodes')->insert($episodes);
|
|
|
- if (!$boolen2) {
|
|
|
- dLog('deepseek')->info('分集内容保存失败', $episodes);
|
|
|
- logDB('deepseek', 'error', '分集内容保存失败', ['episodes_count' => count($episodes)]);
|
|
|
- Utils::throwError('20003:分集内容保存失败');
|
|
|
- }
|
|
|
+ public function delAnime($data) {
|
|
|
+ $anime_id = getProp($data, 'anime_id');
|
|
|
|
|
|
- } catch (\Exception $e) {
|
|
|
- DB::rollBack();
|
|
|
- Utils::throwError('20003:'.$e->getMessage());
|
|
|
+ if (!$anime_id) {
|
|
|
+ Utils::throwError('20003:请选择剧本');
|
|
|
}
|
|
|
- DB::commit();
|
|
|
- return true;
|
|
|
+
|
|
|
+ return DB::table('mp_animes')->where('id', $anime_id)->update([
|
|
|
+ 'is_deleted' => 1,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
public function animeDetail($data) {
|
|
|
@@ -1228,6 +1260,7 @@ class AnimeService
|
|
|
// 如果有对话内容,创建视频配音合成任务
|
|
|
$dialogue = getProp($segment, 'dialogue');
|
|
|
if (!empty($dialogue)) {
|
|
|
+ sleep(1);
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
$generate_json = [
|
|
|
'text' => $dialogue,
|
|
|
@@ -2202,8 +2235,6 @@ class AnimeService
|
|
|
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
-
|
|
|
- $now = date('Y-m-d H:i:s');
|
|
|
|
|
|
// 收集需要创建音频合成任务的segment_id和对应的分镜数据
|
|
|
$segment_ids_to_create_task = [];
|
|
|
@@ -2243,7 +2274,7 @@ class AnimeService
|
|
|
if (!empty($segment_ids_to_create_task)) {
|
|
|
$global_segment_update_data = $global_update_data;
|
|
|
$global_segment_update_data['audio_url'] = ''; // 清空音频URL
|
|
|
- $global_segment_update_data['updated_at'] = $now;
|
|
|
+ $global_segment_update_data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
DB::table('mp_episode_segments')
|
|
|
->where('episode_id', $episode_id)
|
|
|
->where('voice_actor', $target_voice_actor)
|
|
|
@@ -2271,7 +2302,7 @@ class AnimeService
|
|
|
if ($roles_updated) {
|
|
|
DB::table('mp_anime_episodes')->where('id', $episode_id)->update([
|
|
|
'roles' => json_encode($episode_roles, 256),
|
|
|
- 'updated_at' => $now,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
@@ -2307,7 +2338,7 @@ class AnimeService
|
|
|
|
|
|
// 更新分镜数据并清空音频URL
|
|
|
$segment_update_data['audio_url'] = '';
|
|
|
- $segment_update_data['updated_at'] = $now;
|
|
|
+ $segment_update_data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
DB::table('mp_episode_segments')->where('segment_id', $segment_id)->update($segment_update_data);
|
|
|
}
|
|
|
}
|
|
|
@@ -2340,11 +2371,12 @@ class AnimeService
|
|
|
'audio_url' => 'https://zw-audiobook.tos-cn-beijing.volces.com/effects/ellipses_2s.mp3',
|
|
|
'audio_duration' => 2.0,
|
|
|
'subtitle_info' => json_encode(['duration' => 2.0, 'words' => []], 256),
|
|
|
- 'updated_at' => $now
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
]);
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ sleep(1);
|
|
|
$generate_json = [
|
|
|
'text' => $dialogue,
|
|
|
'role' => getProp($updated_segment, 'voice_actor'),
|
|
|
@@ -2365,8 +2397,8 @@ class AnimeService
|
|
|
'generate_status' => '执行中',
|
|
|
'audio_url' => '',
|
|
|
'generate_json' => json_encode($generate_json, 256),
|
|
|
- 'created_at' => $now,
|
|
|
- 'updated_at' => $now,
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s'),
|
|
|
]);
|
|
|
|
|
|
if (!$dubTaskId) {
|
|
|
@@ -2629,6 +2661,26 @@ class AnimeService
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ public function clipSegmentVideo($data) {
|
|
|
+ $segment_id = getProp($data, 'segment_id');
|
|
|
+ $video_time_point_start = getProp($data, 'video_time_point_start');
|
|
|
+ $video_time_point_end = getProp($data, 'video_time_point_end');
|
|
|
+
|
|
|
+ if (!$segment_id || !$video_time_point_start || !$video_time_point_end) {
|
|
|
+ Utils::throwError('20003:参数异常');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!DB::table('mp_episode_segments')->where('segment_id', $segment_id)->value('video_url')) {
|
|
|
+ Utils::throwError('20003:该分镜没有视频,无法裁剪');
|
|
|
+ }
|
|
|
+
|
|
|
+ return DB::table('mp_episode_segments')->where('segment_id', $segment_id)->update([
|
|
|
+ 'video_time_point_start' => $video_time_point_start,
|
|
|
+ 'video_time_point_end' => $video_time_point_end,
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
// 轮训获取图片任务结果
|
|
|
private function loopGetPicTaskResult($task_id) {
|
|
|
$task = MpGeneratePicTask::where('id', $task_id)->first();
|