This commit is contained in:
liubiren 2026-09-23 20:26:27 +08:00
parent 7394757a7c
commit 1adf2556c0
5 changed files with 47 additions and 25 deletions

View File

@ -65,6 +65,7 @@ embedder = Embedder(
), ),
), ),
) )
# 最大分块大小 # 最大分块大小
max_chunk_size: int = cast(int, embedder.max_input_tokens_sync()) max_chunk_size: int = cast(int, embedder.max_input_tokens_sync())
# 分块重叠 # 分块重叠

Binary file not shown.

View File

@ -253,9 +253,9 @@ class Drafts:
video_material = VideoMaterial(path=material_path.as_posix()) video_material = VideoMaterial(path=material_path.as_posix())
# 视频素材的持续时长 # 视频素材的持续时长
video_material_duration = video_material.duration video_material_duration = video_material.duration
# 若视频或图片素材在轨道上的范围为空则将视频素材持续时长作为目标持续时长
if target_timerange: if target_timerange:
target_start, target_duration = target_timerange target_start, target_duration = target_timerange
# 若视频或图片素材在轨道上的范围为空则将视频素材持续时长作为目标持续时长
else: else:
target_start, target_duration = 0, self.video_duration target_start, target_duration = 0, self.video_duration

View File

@ -234,6 +234,11 @@ class DraftsManager:
"add_background_video", "add_background_video",
"add_statement_image", "add_statement_image",
], # 就背景视频添加声明图片 ], # 就背景视频添加声明图片
"移动": [
"add_background_video",
"add_subtitle_video",
"add_post_roll_video",
], # 分别添加背景视频、字幕视频和后贴视频
} }
# 默认以素材文件夹名称为工作流名称 # 默认以素材文件夹名称为工作流名称
workflow_name = self.materials_folder_path.stem workflow_name = self.materials_folder_path.stem
@ -422,18 +427,11 @@ class DraftsManager:
# 若包含添加字幕视频则使用字幕视频时长作为视频时长,否则使用背景视频时长作为视频时长 # 若包含添加字幕视频则使用字幕视频时长作为视频时长,否则使用背景视频时长作为视频时长
if "add_subtitle_video" in configurations: if "add_subtitle_video" in configurations:
video_duration = min( video_duration = VideoMaterial(
VideoMaterial(
path=configurations["add_background_video"][
"material_path"
].as_posix()
).duration,
VideoMaterial(
path=configurations["add_subtitle_video"][ path=configurations["add_subtitle_video"][
"material_path" "material_path"
].as_posix() ].as_posix()
).duration, ).duration
)
else: else:
video_duration = video_duration = VideoMaterial( video_duration = video_duration = VideoMaterial(
path=configurations["add_background_video"][ path=configurations["add_background_video"][
@ -595,15 +593,34 @@ class DraftsManager:
else node_name else node_name
) )
background_video_duration = VideoMaterial( # 背景视频时长,若配置包含添加字幕视频则背景视频时长为字幕视频时长,否则为背景视频时长
background_video_duration = (
VideoMaterial(
path=configurations["add_subtitle_video"]["material_path"].as_posix()
).duration
if "add_subtitle_video" in configurations
else VideoMaterial(
path=configurations["add_background_video"]["material_path"].as_posix() path=configurations["add_background_video"]["material_path"].as_posix()
).duration ).duration
)
# 若截取背景视频时长非空则将背景视频时长设置为截取背景视频时长
if capture_duration: if capture_duration:
background_video_duration = capture_duration * 1_000_000 background_video_duration = capture_duration * 1_000_000
# 若包含添加字幕视频则在添加背景视频时其播放音量设置为 0 # 设置背景视频在轨道上的范围为 (0, 背景视频时长)
configurations["add_background_video"]["target_timerange"] = (
0,
background_video_duration,
)
if "add_subtitle_video" in configurations: if "add_subtitle_video" in configurations:
# 若包含添加字幕视频则在添加背景视频时其播放音量设置为 0
configurations["add_background_video"]["volume"] = 0.0 configurations["add_background_video"]["volume"] = 0.0
# 设置字幕视频在轨道上的范围为 (0, 背景视频时长)
configurations["add_subtitle_video"]["target_timerange"] = (
0,
background_video_duration,
)
# 中贴视频特殊处理:背景视频、背景音频和字幕视频在轨道上的范围为 (0, 背景视频时长),中贴视频在轨道上的范围为 (背景视频时长, 中贴视频时长) # 中贴视频特殊处理:背景视频、背景音频和字幕视频在轨道上的范围为 (0, 背景视频时长),中贴视频在轨道上的范围为 (背景视频时长, 中贴视频时长)
if "add_mid_roll_video" in configurations: if "add_mid_roll_video" in configurations:
@ -649,11 +666,15 @@ class DraftsManager:
"target_timerange": ( "target_timerange": (
( (
background_video_duration background_video_duration
+ VideoMaterial( + (
VideoMaterial(
path=configurations["add_mid_roll_video"][ path=configurations["add_mid_roll_video"][
"material_path" "material_path"
].as_posix() ].as_posix()
).duration ).duration
if "add_mid_roll_video" in configurations
else 0
)
), ),
VideoMaterial( VideoMaterial(
path=configurations["add_post_roll_video"][ path=configurations["add_post_roll_video"][

View File

@ -9,10 +9,10 @@ from drafts_manager import DraftsManager
if __name__ == "__main__": if __name__ == "__main__":
# 实例化 DraftsManager # 实例化 DraftsManager
drafts_manager = DraftsManager( drafts_manager = DraftsManager(
materials_folder_path=r"E:\jianying\materials\存量", materials_folder_path=r"E:\jianying\materials\移动",
) )
# 导出视频 # 批量创建草稿
drafts_manager.batch_create( drafts_manager.batch_create(
draft_counts=1, draft_counts=300,
) )