From c94b11a1f53bae9ed04376cd49d6f9608948d88c Mon Sep 17 00:00:00 2001 From: sun-guannan Date: Tue, 12 Aug 2025 16:56:15 +0800 Subject: [PATCH] add 001-words --- README-zh.md | 3 +++ README.md | 6 +++++- example.py | 2 +- pattern/001-words.py | 29 +++++++++++++++++------------ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README-zh.md b/README-zh.md index f573ab4..7215550 100644 --- a/README-zh.md +++ b/README-zh.md @@ -246,6 +246,9 @@ mcp_client.call_tool("add_text", { 调用 `save_draft` 会在`capcut_server.py`当前目录下生成一个 `dfd_` 开头的文件夹,将其复制到剪映/CapCut 草稿目录,即可在应用中看到生成的草稿。 +## 模版 +我们汇总了一些模版,放在`pattern`文件夹下。 + ## 社区与支持 我们欢迎各种形式的贡献!我们的迭代规则: diff --git a/README.md b/README.md index 0280f24..b6a71ea 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ response = requests.post("http://localhost:9001/add_text", json={ "text": "Welcome to CapCutAPI", "start": 0, "end": 5, - "font": "Source Han Sans", + "font": "Source Han Sans",read "font_color": "#FFD700", "font_size": 48, "shadow_enabled": True, @@ -243,6 +243,10 @@ mcp_client.call_tool("add_text", { Calling `save_draft` will generate a folder starting with `dfd_` in the current directory of `capcut_server.py`. Copy this to the CapCut/Jianying drafts directory to see the generated draft in the application. +## Pattern + +You can find a lot of pattern in the `pattern` directory. + ## Community & Support We welcome contributions of all forms\! Our iteration rules are: diff --git a/example.py b/example.py index cff418f..c2d8f30 100644 --- a/example.py +++ b/example.py @@ -162,7 +162,7 @@ def add_text_impl(text, start, end, font, font_color, font_size, track_name, dra return make_request("add_text", data) -def add_image_impl(image_url, width, height, start, end, track_name, draft_id=None, +def add_image_impl(image_url, start, end, width=None, height=None, track_name="image_main", draft_id=None, transform_x=0, transform_y=0, scale_x=1.0, scale_y=1.0, transition=None, transition_duration=None, mask_type=None, mask_center_x=0.0, mask_center_y=0.0, mask_size=0.5, mask_rotation=0.0, mask_feather=0.0, mask_invert=False, diff --git a/pattern/001-words.py b/pattern/001-words.py index d8232f7..4da9f4c 100644 --- a/pattern/001-words.py +++ b/pattern/001-words.py @@ -5,6 +5,9 @@ import sys import time import json +sys.path.append('/Users/sunguannan/capcutapi') +from example import add_image_impl + PORT=9001 #端口 BASE_URL = f"http://localhost:{PORT}" draft_folder = "/Users/sunguannan/Movies/JianyingPro/User Data/Projects/com.lveditor.draft" @@ -440,73 +443,73 @@ def build_segments_by_mode( return segments corrected_srt = [{ - "word": "你", + "word": "Hello", "start": 0.0, "end": 0.64, "confidence": 0.93917525 }, { - "word": "好", + "word": "I'm", "start": 0.64, "end": 0.79999995, "confidence": 0.9976464 }, { - "word": "我", + "word": "PAWA", "start": 0.79999995, "end": 1.36, "confidence": 0.6848311 }, { - "word": "是", + "word": "Nice", "start": 1.36, "end": 1.52, "confidence": 0.9850389 }, { - "word": "PAWA", + "word": "To", "start": 1.52, "end": 1.68, "confidence": 0.9926886 }, { - "word": "很", + "word": "Meet", "start": 1.68, "end": 2.08, "confidence": 0.9972697 }, { - "word": "高", + "word": "You", "start": 2.08, "end": 2.72, "confidence": 0.9845563 }, { - "word": "兴", + "word": "Enjoy", "start": 2.72, "end": 3.04, "confidence": 0.99794894 }, { - "word": "认", + "word": "My", "start": 3.04, "end": 3.1999998, "confidence": 0.9970203 }, { - "word": "识", + "word": "Parttern", "start": 3.1999998, "end": 3.36, "confidence": 0.9970235 }, { - "word": "大", + "word": "Thank", "start": 3.36, "end": 3.6799998, "confidence": 0.98627764 }, { - "word": "家", + "word": "You", "start": 3.6799998, "end": 4.0, "confidence": 0.9939551 @@ -606,6 +609,8 @@ draft_id = add_koubo_from_srt( ) +add_image_impl(image_url="https://pic1.imgdb.cn/item/689aff2758cb8da5c81e64a2.png", start = 0, end = 4, draft_id=draft_id) + save_result = save_draft_impl(draft_id, draft_folder) print(save_result)