fix
This commit is contained in:
@@ -265,8 +265,11 @@ class MediaManager:
|
||||
return False
|
||||
|
||||
def _split_video_by_scenes(self, video_path: str, scene_changes: List[float],
|
||||
original_video_id: str) -> List[VideoSegment]:
|
||||
original_video_id: str, tags: List[str] = None) -> List[VideoSegment]:
|
||||
"""根据场景变化分割视频"""
|
||||
if tags is None:
|
||||
tags = []
|
||||
|
||||
if not VIDEO_LIBS_AVAILABLE:
|
||||
logger.warning("Video processing not available, creating single segment")
|
||||
# 创建单个片段
|
||||
@@ -294,7 +297,7 @@ class MediaManager:
|
||||
format='mp4',
|
||||
start_time=0.0,
|
||||
end_time=video_info['duration'],
|
||||
tags=[],
|
||||
tags=tags.copy(),
|
||||
use_count=0,
|
||||
created_at=now,
|
||||
updated_at=now
|
||||
@@ -372,7 +375,7 @@ class MediaManager:
|
||||
format='mp4',
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
tags=[],
|
||||
tags=tags.copy(),
|
||||
use_count=0,
|
||||
thumbnail_path=str(thumbnail_path) if thumbnail_generated else None,
|
||||
created_at=now,
|
||||
@@ -387,7 +390,7 @@ class MediaManager:
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to split video: {e}")
|
||||
# 如果分割失败,创建单个片段
|
||||
return self._split_video_by_scenes(video_path, [0.0, self._get_video_info(video_path)['duration']], original_video_id)
|
||||
return self._split_video_by_scenes(video_path, [0.0, self._get_video_info(video_path)['duration']], original_video_id, tags)
|
||||
|
||||
return segments
|
||||
|
||||
@@ -480,9 +483,9 @@ class MediaManager:
|
||||
updated_at=now
|
||||
)
|
||||
|
||||
# 分割视频成片段
|
||||
segments = self._split_video_by_scenes(str(stored_path), scene_changes, video_id)
|
||||
|
||||
# 分割视频成片段,传递标签给片段
|
||||
segments = self._split_video_by_scenes(str(stored_path), scene_changes, video_id, tags)
|
||||
|
||||
# 保存数据
|
||||
self.original_videos.append(original_video)
|
||||
self.video_segments.extend(segments)
|
||||
|
||||
Reference in New Issue
Block a user