This commit is contained in:
root
2025-07-11 16:25:35 +08:00
parent 2076d85023
commit 3e58d597ab
2 changed files with 270 additions and 6 deletions

View File

@@ -270,6 +270,11 @@ class MediaManager:
if tags is None:
tags = []
# 为分镜片段处理标签:去掉"原始",添加"分镜"
segment_tags = [tag for tag in tags if tag != "原始"]
if "分镜" not in segment_tags:
segment_tags.append("分镜")
if not VIDEO_LIBS_AVAILABLE:
logger.warning("Video processing not available, creating single segment")
# 创建单个片段
@@ -297,7 +302,7 @@ class MediaManager:
format='mp4',
start_time=0.0,
end_time=video_info['duration'],
tags=tags.copy(),
tags=segment_tags.copy(),
use_count=0,
created_at=now,
updated_at=now
@@ -375,7 +380,7 @@ class MediaManager:
format='mp4',
start_time=start_time,
end_time=end_time,
tags=tags.copy(),
tags=segment_tags.copy(),
use_count=0,
thumbnail_path=str(thumbnail_path) if thumbnail_generated else None,
created_at=now,
@@ -390,7 +395,11 @@ 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, tags)
# 错误处理时也要处理标签
segment_tags = [tag for tag in tags if tag != "原始"] if tags else []
if "分镜" not in segment_tags:
segment_tags.append("分镜")
return self._split_video_by_scenes(video_path, [0.0, self._get_video_info(video_path)['duration']], original_video_id, segment_tags)
return segments
@@ -482,9 +491,12 @@ class MediaManager:
created_at=now,
updated_at=now
)
# 分割视频成片段,传递标签给片段
segments = self._split_video_by_scenes(str(stored_path), scene_changes, video_id, tags)
# 分割视频成片段,传递标签给片段(去掉"原始",添加"分镜"
segment_tags = [tag for tag in tags if tag != "原始"]
if "分镜" not in segment_tags:
segment_tags.append("分镜")
segments = self._split_video_by_scenes(str(stored_path), scene_changes, video_id, segment_tags)
# 保存数据
self.original_videos.append(original_video)