|
|
@@ -233,6 +233,10 @@ class AIVideoGenerationService
|
|
|
// 将视频另存到tos
|
|
|
$url = uploadStreamByTos('video', file_get_contents($result['video_url']), $video_name);
|
|
|
$returnData['result_url'] = $url;
|
|
|
+
|
|
|
+ // 压缩视频
|
|
|
+ $compressed_video_url = compressVideo($url);
|
|
|
+ $returnData['compressed_url'] = $compressed_video_url ?: $url;
|
|
|
}
|
|
|
|
|
|
// 计算视频时长
|
|
|
@@ -321,7 +325,6 @@ class AIVideoGenerationService
|
|
|
|
|
|
if ($statusInfo['status'] === 'success') {
|
|
|
logDB('generate', 'info', '即梦AI视频生成任务成功', ['id' => $task->id, 'result_url' => $statusInfo['result_url']]);
|
|
|
- $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
|
|
|
// 同步调整分镜视频状态和结果(兼容全能模式)
|
|
|
$segment_id = $this->getSegmentIdFromTask($task);
|
|
|
@@ -329,6 +332,9 @@ class AIVideoGenerationService
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ // 在事务中更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
+
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
|
|
|
// 构建更新数据
|
|
|
@@ -339,8 +345,9 @@ class AIVideoGenerationService
|
|
|
'last_frame_url' => $statusInfo['last_frame_url'] ?? '',
|
|
|
'updated_at' => $now
|
|
|
];
|
|
|
- $compressed_video_url = compressVideo($statusInfo['result_url']);
|
|
|
- $segmentUpdateData['video_url'] = $compressed_video_url ?: $statusInfo['result_url'];
|
|
|
+
|
|
|
+ // 使用查询任务时已压缩的视频URL,避免重复压缩
|
|
|
+ $segmentUpdateData['video_url'] = $statusInfo['compressed_url'] ?? $statusInfo['result_url'];
|
|
|
|
|
|
// 只有当video_duration存在且大于0时才更新
|
|
|
if (isset($statusInfo['video_duration']) && $statusInfo['video_duration'] > 0) {
|
|
|
@@ -367,6 +374,9 @@ class AIVideoGenerationService
|
|
|
'error' => $e->getMessage()
|
|
|
]);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 没有segment_id的情况下,直接更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
}
|
|
|
} elseif ($statusInfo['status'] === 'failed') {
|
|
|
logDB('generate', 'error', '即梦AI视频生成任务失败', ['id' => $task->id, 'error' => $statusInfo['error_message']]);
|
|
|
@@ -586,7 +596,6 @@ class AIVideoGenerationService
|
|
|
|
|
|
if ($statusInfo['status'] === 'success') {
|
|
|
logDB('generate', 'info', 'Seedance视频生成任务成功', ['id' => $task->id, 'result_url' => $statusInfo['result_url']]);
|
|
|
- $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
|
|
|
// 同步调整分镜视频状态和结果(兼容全能模式)
|
|
|
$segment_id = $this->getSegmentIdFromTask($task);
|
|
|
@@ -594,6 +603,9 @@ class AIVideoGenerationService
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ // 在事务中更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
+
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
|
|
|
// 构建更新数据
|
|
|
@@ -604,8 +616,9 @@ class AIVideoGenerationService
|
|
|
'last_frame_url' => $statusInfo['last_frame_url'] ?? '',
|
|
|
'updated_at' => $now
|
|
|
];
|
|
|
- $compressed_video_url = compressVideo($statusInfo['result_url']);
|
|
|
- $segmentUpdateData['video_url'] = $compressed_video_url ?: $statusInfo['result_url'];
|
|
|
+
|
|
|
+ // 使用查询任务时已压缩的视频URL,避免重复压缩
|
|
|
+ $segmentUpdateData['video_url'] = $statusInfo['compressed_url'] ?? $statusInfo['result_url'];
|
|
|
|
|
|
// 只有当video_duration存在且大于0时才更新
|
|
|
if (isset($statusInfo['video_duration']) && $statusInfo['video_duration'] > 0) {
|
|
|
@@ -633,6 +646,9 @@ class AIVideoGenerationService
|
|
|
'error' => $e->getMessage()
|
|
|
]);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 没有segment_id的情况下,直接更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
}
|
|
|
} elseif ($statusInfo['status'] === 'failed') {
|
|
|
logDB('generate', 'error', 'Seedance视频生成任务失败', ['id' => $task->id, 'error' => $statusInfo['error_message']]);
|
|
|
@@ -1381,6 +1397,10 @@ class AIVideoGenerationService
|
|
|
$url = uploadStreamByTos('video', file_get_contents($video_url), $video_name);
|
|
|
$updateData['result_url'] = $url;
|
|
|
|
|
|
+ // 压缩视频
|
|
|
+ $compressed_video_url = compressVideo($url);
|
|
|
+ $updateData['compressed_url'] = $compressed_video_url ?: $url;
|
|
|
+
|
|
|
// 计算视频时长
|
|
|
$video_duration = 0;
|
|
|
if (isset($video['duration'])) {
|
|
|
@@ -1477,7 +1497,6 @@ class AIVideoGenerationService
|
|
|
|
|
|
if ($statusInfo['status'] === 'success') {
|
|
|
logDB('generate', 'info', '可灵AI Omni视频生成任务成功', ['id' => $task->id, 'result_url' => $statusInfo['result_url']]);
|
|
|
- $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
|
|
|
// 同步调整分镜视频状态和结果(兼容全能模式)
|
|
|
$segment_id = $this->getSegmentIdFromTask($task);
|
|
|
@@ -1485,6 +1504,9 @@ class AIVideoGenerationService
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ // 在事务中更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
+
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
|
|
|
// 构建更新数据
|
|
|
@@ -1495,8 +1517,9 @@ class AIVideoGenerationService
|
|
|
'last_frame_url' => $statusInfo['last_frame_url'] ?? '',
|
|
|
'updated_at' => $now
|
|
|
];
|
|
|
- $compressed_video_url = compressVideo($statusInfo['result_url']);
|
|
|
- $segmentUpdateData['video_url'] = $compressed_video_url ?: $statusInfo['result_url'];
|
|
|
+
|
|
|
+ // 使用查询任务时已压缩的视频URL,避免重复压缩
|
|
|
+ $segmentUpdateData['video_url'] = $statusInfo['compressed_url'] ?? $statusInfo['result_url'];
|
|
|
|
|
|
// 只有当video_duration存在且大于0时才更新
|
|
|
if (isset($statusInfo['video_duration']) && $statusInfo['video_duration'] > 0) {
|
|
|
@@ -1524,6 +1547,9 @@ class AIVideoGenerationService
|
|
|
'error' => $e->getMessage()
|
|
|
]);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 没有segment_id的情况下,直接更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
}
|
|
|
} elseif ($statusInfo['status'] === 'failed') {
|
|
|
$task->updateStatus(MpGenerateVideoTask::STATUS_FAILED, [
|
|
|
@@ -2458,6 +2484,10 @@ class AIVideoGenerationService
|
|
|
$video_name = $video_name . $video_ext;
|
|
|
$url = uploadStreamByTos('video', file_get_contents($videoUrl), $video_name);
|
|
|
$returnData['result_url'] = $url;
|
|
|
+
|
|
|
+ // 压缩视频
|
|
|
+ $compressed_video_url = compressVideo($url);
|
|
|
+ $returnData['compressed_url'] = $compressed_video_url ?: $url;
|
|
|
} catch (\Exception $e) {
|
|
|
dLog('generate')->error('保存视频到TOS失败', ['error' => $e->getMessage()]);
|
|
|
$returnData['result_url'] = $videoUrl; // 如果保存失败,使用原URL
|
|
|
@@ -2530,7 +2560,6 @@ class AIVideoGenerationService
|
|
|
|
|
|
if ($statusInfo['status'] === 'success') {
|
|
|
logDB('generate', 'info', '统一API视频生成任务成功', ['id' => $task->id, 'result_url' => $statusInfo['result_url']]);
|
|
|
- $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
|
|
|
// 同步调整分镜视频状态和结果(兼容全能模式)
|
|
|
$segment_id = $this->getSegmentIdFromTask($task);
|
|
|
@@ -2538,6 +2567,9 @@ class AIVideoGenerationService
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
+ // 在事务中更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
+
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
|
|
|
// 构建更新数据
|
|
|
@@ -2548,8 +2580,9 @@ class AIVideoGenerationService
|
|
|
'last_frame_url' => $statusInfo['last_frame_url'] ?? '',
|
|
|
'updated_at' => $now
|
|
|
];
|
|
|
- $compressed_video_url = compressVideo($statusInfo['result_url']);
|
|
|
- $segmentUpdateData['video_url'] = $compressed_video_url ?: $statusInfo['result_url'];
|
|
|
+
|
|
|
+ // 使用查询任务时已压缩的视频URL,避免重复压缩
|
|
|
+ $segmentUpdateData['video_url'] = $statusInfo['compressed_url'] ?? $statusInfo['result_url'];
|
|
|
|
|
|
// 只有当video_duration存在且大于0时才更新
|
|
|
if (isset($statusInfo['video_duration']) && $statusInfo['video_duration'] > 0) {
|
|
|
@@ -2577,6 +2610,9 @@ class AIVideoGenerationService
|
|
|
'error' => $e->getMessage()
|
|
|
]);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 没有segment_id的情况下,直接更新任务状态
|
|
|
+ $task->updateStatus(MpGenerateVideoTask::STATUS_SUCCESS, $statusInfo);
|
|
|
}
|
|
|
} elseif ($statusInfo['status'] === 'failed') {
|
|
|
logDB('generate', 'error', '统一API视频生成任务失败', ['id' => $task->id, 'error' => $statusInfo['error_message']]);
|