lh 3 months ago
parent
commit
fb8ebdba64

+ 19 - 26
app/Http/Controllers/AIGeneration/VideoGenerationController.php

@@ -260,14 +260,14 @@ class VideoGenerationController extends BaseController
         
         
         // 验证基本参数
         // 验证基本参数
         $baseRules = [
         $baseRules = [
-            'model' => 'required|string|in:doubao-seedance-1-5-pro-251215,doubao-seedance-1-0-pro-250528,doubao-seedance-1-0-pro-fast-251015,doubao-seedance-1-0-lite-t2v-250428,doubao-seedance-1-0-lite-i2v-250428',
+            'model' => 'required|string|in:doubao-seedance-1-5-pro-251215,doubao-seedance-1-0-pro-250528,doubao-seedance-1-0-pro-fast-251015',
             'prompt' => 'required|max:1000',
             'prompt' => 'required|max:1000',
             // 'content' => 'required|array|min:1',
             // 'content' => 'required|array|min:1',
         ];
         ];
         
         
         $baseMessages = [
         $baseMessages = [
             'model.required' => '模型参数不能为空',
             'model.required' => '模型参数不能为空',
-            'model.in' => '模型只支持 doubao-seedance-1-5-pro-251215、doubao-seedance-1-0-pro-250528、doubao-seedance-1-0-pro-fast-251015、doubao-seedance-1-0-lite-t2v-250428、doubao-seedance-1-0-lite-i2v-250428',
+            'model.in' => '模型只支持 doubao-seedance-1-5-pro-251215、doubao-seedance-1-0-pro-250528、doubao-seedance-1-0-pro-fast-251015',
             'prompt.required' => '提示词不能为空',
             'prompt.required' => '提示词不能为空',
             'prompt.max' => '提示词不能超过1000个字符',
             'prompt.max' => '提示词不能超过1000个字符',
             // 'content.required' => '内容参数不能为空',
             // 'content.required' => '内容参数不能为空',
@@ -373,22 +373,19 @@ class VideoGenerationController extends BaseController
         $tailFrame = null;
         $tailFrame = null;
 
 
         // 以下首尾帧做模型兼容:
         // 以下首尾帧做模型兼容:
-        // doubao-seedance-1-0-lite-t2v-250428只支持文生视频
         // doubao-seedance-1-0-pro-fast-251015只支持文生视频、图生视频-首帧
         // doubao-seedance-1-0-pro-fast-251015只支持文生视频、图生视频-首帧
         // 处理首帧图片(文件上传方式)
         // 处理首帧图片(文件上传方式)
         if ($request->hasFile('first_frame_file')) {
         if ($request->hasFile('first_frame_file')) {
             $firstFrameFile = $request->file('first_frame_file');
             $firstFrameFile = $request->file('first_frame_file');
             $firstFrame = $this->processFrameFile($firstFrameFile, 'first');
             $firstFrame = $this->processFrameFile($firstFrameFile, 'first');
-            if (!in_array($data['model'], ['doubao-seedance-1-0-lite-t2v-250428'])) {
-                $data['first_frame_url'] = $firstFrame['url'];
-                $data['content'][] = [
-                    'type' => 'image_url',
-                    'image_url' => [
-                        'url' => $data['first_frame_url'],
-                    ],
-                    'role' => 'first_frame',
-                ];
-            }
+            $data['first_frame_url'] = $firstFrame['url'];
+            $data['content'][] = [
+                'type' => 'image_url',
+                'image_url' => [
+                    'url' => $data['first_frame_url'],
+                ],
+                'role' => 'first_frame',
+            ];
         }
         }
         // 处理首帧图片(URL方式)
         // 处理首帧图片(URL方式)
         elseif (isset($data['first_frame_url']) && !empty($data['first_frame_url'])) {
         elseif (isset($data['first_frame_url']) && !empty($data['first_frame_url'])) {
@@ -396,24 +393,20 @@ class VideoGenerationController extends BaseController
             if (!$firstFrame) {
             if (!$firstFrame) {
                 Utils::throwError('1003:首帧图片获取失败');
                 Utils::throwError('1003:首帧图片获取失败');
             }
             }
-            if (!in_array($data['model'], ['doubao-seedance-1-0-lite-t2v-250428'])) {
-                $data['content'][] = [
-                    'type' => 'image_url',
-                    'image_url' => [
-                        'url' => $data['first_frame_url'],
-                    ],
-                    'role' => 'first_frame',
-                ];
-            }else {
-                $data['first_frame_url'] = '';
-            }
+            $data['content'][] = [
+                'type' => 'image_url',
+                'image_url' => [
+                    'url' => $data['first_frame_url'],
+                ],
+                'role' => 'first_frame',
+            ];
         }
         }
 
 
         // 处理尾帧图片(文件上传方式)
         // 处理尾帧图片(文件上传方式)
         if ($request->hasFile('tail_frame_file')) {
         if ($request->hasFile('tail_frame_file')) {
             $tailFrameFile = $request->file('tail_frame_file');
             $tailFrameFile = $request->file('tail_frame_file');
             $tailFrame = $this->processFrameFile($tailFrameFile, 'tail');
             $tailFrame = $this->processFrameFile($tailFrameFile, 'tail');
-            if (!in_array($data['model'], ['doubao-seedance-1-0-lite-t2v-250428', 'doubao-seedance-1-0-pro-fast-251015'])) {
+            if (!in_array($data['model'], ['doubao-seedance-1-0-pro-fast-251015'])) {
                 $data['tail_frame_url'] = $tailFrame['url'];
                 $data['tail_frame_url'] = $tailFrame['url'];
                 $data['content'][] = [
                 $data['content'][] = [
                     'type' => 'image_url',
                     'type' => 'image_url',
@@ -431,7 +424,7 @@ class VideoGenerationController extends BaseController
                 Utils::throwError('1003:尾帧图片获取失败');
                 Utils::throwError('1003:尾帧图片获取失败');
             }
             }
             
             
-            if (!in_array($data['model'], ['doubao-seedance-1-0-lite-t2v-250428', 'doubao-seedance-1-0-pro-fast-251015'])) {
+            if (!in_array($data['model'], ['doubao-seedance-1-0-pro-fast-251015'])) {
                 $data['content'][] = [
                 $data['content'][] = [
                     'type' => 'image_url',
                     'type' => 'image_url',
                     'image_url' => [
                     'image_url' => [

+ 2 - 66
app/Http/Controllers/Anime/AnimeController.php

@@ -523,7 +523,8 @@ class AnimeController extends BaseController
                 }
                 }
                 
                 
                 // 智能选择视频时长
                 // 智能选择视频时长
-                $videoDuration = $this->calculateOptimalVideoDuration($segmentContent, $tailFrame);
+                // $videoDuration = $this->AnimeService->calculateOptimalVideoDuration($segmentContent, $tailFrame);
+                $videoDuration = -1;
                 
                 
                 // 构建视频生成参数
                 // 构建视频生成参数
                 $videoParams = [
                 $videoParams = [
@@ -865,71 +866,6 @@ class AnimeController extends BaseController
         ]);
         ]);
     }
     }
 
 
-    /**
-     * 计算最优视频时长(从 AnimeService 复制)
-     */
-    private function calculateOptimalVideoDuration($segmentContent, $tailFrame = '') {
-        // 基础时长
-        $baseDuration = 4;
-        
-        // 根据内容长度调整
-        $contentLength = mb_strlen($segmentContent);
-        if ($contentLength > 200) {
-            $baseDuration += 2;
-        } elseif ($contentLength > 100) {
-            $baseDuration += 1;
-        }
-        
-        // 根据内容复杂度调整
-        $complexity = $this->analyzeContentComplexity($segmentContent);
-        if ($complexity > 0.7) {
-            $baseDuration += 2;
-        } elseif ($complexity > 0.5) {
-            $baseDuration += 1;
-        }
-        
-        // 如果有尾帧描述,增加时长
-        if (!empty($tailFrame)) {
-            $baseDuration += 1;
-        }
-        
-        // 限制在合理范围内
-        return min(max($baseDuration, 4), 12);
-    }
-
-    /**
-     * 分析内容复杂度(从 AnimeService 复制)
-     */
-    private function analyzeContentComplexity($text) {
-        $complexity = 0;
-        
-        // 动作词汇
-        $actionWords = ['跑', '跳', '飞', '战斗', '攻击', '移动', '转身', '冲刺', '闪避', '追逐'];
-        foreach ($actionWords as $word) {
-            if (strpos($text, $word) !== false) {
-                $complexity += 0.1;
-            }
-        }
-        
-        // 场景变化词汇
-        $sceneWords = ['切换', '转场', '变化', '移动', '远景', '近景', '特写'];
-        foreach ($sceneWords as $word) {
-            if (strpos($text, $word) !== false) {
-                $complexity += 0.15;
-            }
-        }
-        
-        // 情感词汇
-        $emotionWords = ['激动', '愤怒', '悲伤', '惊讶', '恐惧', '兴奋'];
-        foreach ($emotionWords as $word) {
-            if (strpos($text, $word) !== false) {
-                $complexity += 0.05;
-            }
-        }
-        
-        return min($complexity, 1.0);
-    }
-
     // public function scriptList(Request $request) {
     // public function scriptList(Request $request) {
     //     $data = $request->all();
     //     $data = $request->all();
     //     $result = $this->AnimeService->scriptList($data);
     //     $result = $this->AnimeService->scriptList($data);

+ 3 - 2
app/Services/Anime/AnimeService.php

@@ -1565,7 +1565,8 @@ class AnimeService
         }
         }
         
         
         // 智能选择视频时长
         // 智能选择视频时长
-        $videoDuration = $this->calculateOptimalVideoDuration($segmentContent, $tail_frame);
+        // $videoDuration = $this->calculateOptimalVideoDuration($segmentContent, $tail_frame);
+        $videoDuration = -1;
         
         
         // 构建视频生成参数
         // 构建视频生成参数
         $videoParams = [
         $videoParams = [
@@ -1634,7 +1635,7 @@ class AnimeService
      * @param string $tailFrame 尾帧描述
      * @param string $tailFrame 尾帧描述
      * @return int 视频时长(2-12秒)
      * @return int 视频时长(2-12秒)
      */
      */
-    private function calculateOptimalVideoDuration($segmentContent, $tailFrame = '') {
+    public function calculateOptimalVideoDuration($segmentContent, $tailFrame = '') {
         // 合并所有文本内容
         // 合并所有文本内容
         $fullText = trim($segmentContent . ' ' . $tailFrame);
         $fullText = trim($segmentContent . ' ' . $tailFrame);