This commit is contained in:
parent
33f8edcd86
commit
16bc398f39
|
|
@ -31,9 +31,8 @@ class JianYingExport:
|
|||
def __init__(
|
||||
self,
|
||||
materials_folder_path: str,
|
||||
program_path: str = "E:\\JianYingPro\\5.9.0.11632\\JianYingPro.exe", # 仅可在windows运行该脚本
|
||||
drafts_folder_path: str = "E:\\JianYingPro Drafts",
|
||||
draft_counts: int = 10,
|
||||
program_path: str = r"E:\JianYingPro\5.9.0.11632\JianYingPro.exe", # 仅可在windows运行该脚本
|
||||
drafts_folder_path: str = r"E:\JianYingPro Drafts",
|
||||
video_width: int = 1080,
|
||||
video_height: int = 1920,
|
||||
video_fps: int = 30,
|
||||
|
|
@ -43,7 +42,6 @@ class JianYingExport:
|
|||
:param program_path: 剪映程序路径
|
||||
:param drafts_folder_path: 剪映草稿文件夹路径
|
||||
:param materials_folder_path: 素材文件夹路径
|
||||
:param draft_counts: 草稿数,默认为 10
|
||||
:param video_width: 视频宽度,默认为 1080像素
|
||||
:param video_height: 视频高度,默认为 1920像素
|
||||
:param video_fps: 视频帧率(单位为帧/秒),默认为 30
|
||||
|
|
@ -301,7 +299,6 @@ class JianYingExport:
|
|||
self.video_width, self.video_height = video_width, video_height
|
||||
self.video_fps = video_fps
|
||||
|
||||
self.draft_counts = draft_counts
|
||||
# 初始化所有草稿名称
|
||||
self.draft_names = []
|
||||
|
||||
|
|
@ -409,22 +406,21 @@ class JianYingExport:
|
|||
else:
|
||||
self.materials["statement_video_material_path"] = []
|
||||
|
||||
def export(self, workflow_name: str = "0001", batch_draft_counts: int = 1):
|
||||
def export_videos(self, workflow: str, draft_counts: int):
|
||||
"""
|
||||
导出草稿
|
||||
:param workflow_name: 工作流名称
|
||||
:param batch_draft_counts: 每批次导出草稿数
|
||||
导出视频
|
||||
:param workflow: 工作流名称
|
||||
:param draft_counts: 每批次导出草稿数
|
||||
"""
|
||||
if workflow_name not in self.workflows:
|
||||
if workflow not in self.workflows:
|
||||
raise RuntimeError(f"未配置该工作流")
|
||||
self.workflow = self.workflows[workflow_name]
|
||||
|
||||
self.workflow = self.workflows[workflow]
|
||||
# 若工作流包含添加背景音频,则将添加背景视频工作配置中播放音量设置为0
|
||||
if "add_background_audio" in self.workflow:
|
||||
self.configuration["add_background_video"]["volume"] = [0.0]
|
||||
|
||||
# 按照工作流和工作配置拼接素材,批量生成草稿
|
||||
self._generate_drafts()
|
||||
self._generate_drafts(draft_counts=draft_counts)
|
||||
|
||||
# 批次导出
|
||||
for batch_start in range(0, self.draft_counts, batch_draft_counts):
|
||||
|
|
@ -464,15 +460,17 @@ class JianYingExport:
|
|||
|
||||
def _generate_drafts(
|
||||
self,
|
||||
draft_counts: int,
|
||||
) -> None:
|
||||
"""
|
||||
按照工作流和工作配置拼接素材,批量生成草稿
|
||||
:param draft_counts: 草稿数
|
||||
:return: 无
|
||||
"""
|
||||
for idx in range(self.draft_counts):
|
||||
for idx in range(1, draft_counts + 1):
|
||||
# 构建草稿名称
|
||||
draft_name = self.project_name + f"{idx + 1:03d}"
|
||||
print(f"正在合成短视频 {draft_name}, {idx + 1}/{self.draft_counts}...")
|
||||
draft_name = self.project_name + f"{idx:03d}"
|
||||
print(f"正在合成短视频 {draft_name}, {idx}/{draft_counts}...")
|
||||
|
||||
# 实例化 JianYingDraft
|
||||
draft = JianYingDraft(
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ if __name__ == "__main__":
|
|||
# 实例化 JianYingExport
|
||||
jianying_export = JianYingExport(
|
||||
materials_folder_path=r"E:\jianying\materials\淘宝闪购模版001",
|
||||
draft_counts=1,
|
||||
draft_counts=10,
|
||||
)
|
||||
|
||||
# 导出草稿
|
||||
jianying_export.export(workflow_name="0001")
|
||||
# 导出视频
|
||||
jianying_export.export_videos(workflow_name="0001")
|
||||
|
|
|
|||
Loading…
Reference in New Issue