diff --git a/agent/application/preprocessing.py b/agent/application/preprocessing.py index f17c313..58dba34 100644 --- a/agent/application/preprocessing.py +++ b/agent/application/preprocessing.py @@ -65,6 +65,7 @@ embedder = Embedder( ), ), ) + # 最大分块大小 max_chunk_size: int = cast(int, embedder.max_input_tokens_sync()) # 分块重叠 diff --git a/短视频合成自动化/caches.db b/短视频合成自动化/caches.db index 8819dc3..6183601 100644 Binary files a/短视频合成自动化/caches.db and b/短视频合成自动化/caches.db differ diff --git a/短视频合成自动化/drafts.py b/短视频合成自动化/drafts.py index f819bdc..9d6a6e4 100644 --- a/短视频合成自动化/drafts.py +++ b/短视频合成自动化/drafts.py @@ -253,9 +253,9 @@ class Drafts: video_material = VideoMaterial(path=material_path.as_posix()) # 视频素材的持续时长 video_material_duration = video_material.duration + # 若视频或图片素材在轨道上的范围为空则将视频素材持续时长作为目标持续时长 if target_timerange: target_start, target_duration = target_timerange - # 若视频或图片素材在轨道上的范围为空则将视频素材持续时长作为目标持续时长 else: target_start, target_duration = 0, self.video_duration diff --git a/短视频合成自动化/drafts_manager.py b/短视频合成自动化/drafts_manager.py index 6511580..ef06b0b 100644 --- a/短视频合成自动化/drafts_manager.py +++ b/短视频合成自动化/drafts_manager.py @@ -234,6 +234,11 @@ class DraftsManager: "add_background_video", "add_statement_image", ], # 就背景视频添加声明图片 + "移动": [ + "add_background_video", + "add_subtitle_video", + "add_post_roll_video", + ], # 分别添加背景视频、字幕视频和后贴视频 } # 默认以素材文件夹名称为工作流名称 workflow_name = self.materials_folder_path.stem @@ -422,18 +427,11 @@ class DraftsManager: # 若包含添加字幕视频则使用字幕视频时长作为视频时长,否则使用背景视频时长作为视频时长 if "add_subtitle_video" in configurations: - video_duration = min( - VideoMaterial( - path=configurations["add_background_video"][ - "material_path" - ].as_posix() - ).duration, - VideoMaterial( - path=configurations["add_subtitle_video"][ - "material_path" - ].as_posix() - ).duration, - ) + video_duration = VideoMaterial( + path=configurations["add_subtitle_video"][ + "material_path" + ].as_posix() + ).duration else: video_duration = video_duration = VideoMaterial( path=configurations["add_background_video"][ @@ -595,15 +593,34 @@ class DraftsManager: else node_name ) - background_video_duration = VideoMaterial( - path=configurations["add_background_video"]["material_path"].as_posix() - ).duration + # 背景视频时长,若配置包含添加字幕视频则背景视频时长为字幕视频时长,否则为背景视频时长 + 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() + ).duration + ) + # 若截取背景视频时长非空则将背景视频时长设置为截取背景视频时长 if capture_duration: 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: + # 若包含添加字幕视频则在添加背景视频时其播放音量设置为 0 configurations["add_background_video"]["volume"] = 0.0 + # 设置字幕视频在轨道上的范围为 (0, 背景视频时长) + configurations["add_subtitle_video"]["target_timerange"] = ( + 0, + background_video_duration, + ) # 中贴视频特殊处理:背景视频、背景音频和字幕视频在轨道上的范围为 (0, 背景视频时长),中贴视频在轨道上的范围为 (背景视频时长, 中贴视频时长) if "add_mid_roll_video" in configurations: @@ -649,11 +666,15 @@ class DraftsManager: "target_timerange": ( ( background_video_duration - + VideoMaterial( - path=configurations["add_mid_roll_video"][ - "material_path" - ].as_posix() - ).duration + + ( + VideoMaterial( + path=configurations["add_mid_roll_video"][ + "material_path" + ].as_posix() + ).duration + if "add_mid_roll_video" in configurations + else 0 + ) ), VideoMaterial( path=configurations["add_post_roll_video"][ diff --git a/短视频合成自动化/main.py b/短视频合成自动化/main.py index 4aae234..1685014 100644 --- a/短视频合成自动化/main.py +++ b/短视频合成自动化/main.py @@ -9,10 +9,10 @@ from drafts_manager import DraftsManager if __name__ == "__main__": # 实例化 DraftsManager drafts_manager = DraftsManager( - materials_folder_path=r"E:\jianying\materials\存量", + materials_folder_path=r"E:\jianying\materials\移动", ) - # 导出视频 + # 批量创建草稿 drafts_manager.batch_create( - draft_counts=1, + draft_counts=300, )