# CapCutAPI **Repository Path**: yangshare/CapCutAPI ## Basic Information - **Project Name**: CapCutAPI - **Description**: 这是一个基于 Python 开发的开源项目,可通过代码自动化控制剪映 / CapCut 剪辑视频。它能自动创建和管理剪映草稿文件,支持批量操作,还可添加多种素材类型,应用转场、滤镜等特效,集成 AI 服务智能生成字幕和文本内容,并且提供了完整的 HTTP API 接口,方便远程调用。安装 Python 环境和 ffmpeg 后,通过 pip 安装依赖即可使用。 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 4 - **Created**: 2025-07-28 - **Last Updated**: 2025-11-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CapCutAPI Open source CapCut API tool. [中文说明](https://github.com/sun-guannan/CapCutAPI/blob/main/README-zh.md) ## Project Features This project is a Python-based CapCut processing tool that offers the following core functionalities: ### Core Features - **Draft File Management**: Create, read, modify, and save CapCut draft files - **Material Processing**: Support adding and editing various materials such as videos, audios, images, texts, stickers, etc. - **Effect Application**: Support adding multiple effects like transitions, filters, masks, animations, etc. - **API Service**: Provide HTTP API interfaces to support remote calls and automated processing - **AI Integration**: Integrate multiple AI services to support intelligent generation of subtitles, texts, and images ### Main API Interfaces - `/create_draft`: Create a draft - `/add_video`: Add video material to the draft - `/add_audio`: Add audio material to the draft - `/add_image`: Add image material to the draft - `/add_text`: Add text material to the draft - `/add_subtitle`: Add subtitles to the draft - `/add_effect`: Add effects to materials - `/add_sticker`: Add stickers to the draft - `/save_draft`: Save the draft file ## Configuration Instructions ### Configuration File The project supports custom settings through a configuration file. To use the configuration file: 1. Copy `config.json.example` to `config.json` 2. Modify the configuration items as needed ```bash cp config.json.example config.json ``` ### Environment Configuration #### ffmpeg This project depends on ffmpeg. You need to ensure that ffmpeg is installed on your system and added to the system's environment variables. #### Python Environment This project requires Python version 3.8.20. Please ensure that the correct version of Python is installed on your system. #### Install Dependencies Install the required dependency packages for the project: ```bash pip install -r requirements.txt ``` ### Run the Server After completing the configuration and environment setup, execute the following command to start the server: ```bash python capcut_server.py ``` Once the server is started, you can access the related functions through the API interfaces. ## Usage Examples ### Adding a Video ```python import requests response = requests.post("http://localhost:9001/add_video", json={ "video_url": "http://example.com/video.mp4", "start": 0, "end": 10, "width": 1080, "height": 1920 }) print(response.json()) ``` ### Adding Text ```python import requests response = requests.post("http://localhost:9001/add_text", json={ "text": "Hello, World!", "start": 0, "end": 3, "font": "ZY_Courage", "font_color": "#FF0000", "font_size": 30.0 }) print(response.json()) ``` ### Saving a Draft ```python import requests response = requests.post("http://localhost:9001/save_draft", json={ "draft_id": "123456", "draft_folder": "your capcut draft folder" }) print(response.json()) ``` You can also use the ```rest_client_test.http``` file of the REST Client for HTTP testing. Just need to install the corresponding IDE plugin ### Copying the Draft to CapCut Draft Path Calling `save_draft` will generate a folder starting with `dfd_` in the current directory of the server. Copy this folder to the CapCut draft directory, and you will be able to see the generated draft. ### More Examples Please refer to the `example.py` file in the project, which contains more usage examples such as adding audio and effects. ## Project Features - **Cross-platform Support**: Supports both CapCut China version and CapCut International version - **Automated Processing**: Supports batch processing and automated workflows - **Rich APIs**: Provides comprehensive API interfaces for easy integration into other systems - **Flexible Configuration**: Achieve flexible function customization through configuration files - **AI Enhancement**: Integrate multiple AI services to improve video production efficiency