CapCutAPI is an open source project hosted on GitHub and created by developer sun-guannan. It is based on Python development , designed to automate the control of CapCut ( cut image ) through the code for video editing . Users can automate video editing by writing scripts that include features such as creating drafts, adding clips, applying effects, and generating subtitles. The tool is suitable for developers and content creators who need to batch process videos or are looking for efficient editing. The project is currently in an active development phase, with detailed documentation and sample code provided for users to get started quickly.The core goal of CapCutAPI is to simplify the video editing process, reduce manual operation time, and improve creative efficiency.
Function List
- Automatic creation of draft video clips and support for quick initialization of projects.
- Supports adding videos, pictures, audio and many other materials.
- Provides automated applications for video effects and transitions.
- Integrated AI services, automatic subtitle generation and multi-language support.
- Supports batch processing of videos, suitable for large-scale content production.
- Provides scripted controls that allow users to customize clip logic.
- Support exporting watermark-free videos to meet professional needs.
Using Help
CapCutAPI is a Python-based open-source tool designed to help users automate video editing by controlling CapCut (clipping) through code. Below is a detailed installation and usage guide to help users get started quickly.
Installation process
- environmental preparation
Make sure you have Python 3.8 or above installed on your computer. You can check the Python version with the following command:python --version
If Python is not installed, start the Python Official Website Download and install.
- cloning project
CapCutAPI is hosted on GitHub. You need to clone the project locally using Git. Open a terminal and run the following command:git clone https://github.com/sun-guannan/CapCutAPI.git
If you don't have Git installed, you can get it from Git website Download.
- Installation of dependencies
Go to the project catalog:cd CapCutAPI
Project dependencies are listed in the
requirements.txt
file. Install the dependencies:pip install -r requirements.txt
Ensure that your network connection is working and that your dependencies include common Python libraries such as
requests
cap (a poem)pydub
The - Configuring CapCut
CapCutAPI is required to work with installed CapCut software. Please make sure that your computer or device has the latest version of CapCut installed (available in the CapCut Official Website (Download). Some features may require CapCut Professional, it is recommended to check if your version of CapCut supports API calls. - Setting environment variables
Some features, such as AI subtitle generation, require an API key to be configured. Save the key in an environment variable or in the project configuration fileconfig.json
in the project root directory. Refer to the project root directory for details on how to configure theREADME.md
Documentation.
Usage
The core of CapCutAPI is to control CapCut's editing functions through Python scripts. Below is a detailed flow of the main functions.
Creating Video Drafts
(of a computer) run create_draft.py
The script creates a new draft CapCut project. Sample Code:
from capcut_api import CapCutAPI
api = CapCutAPI()
draft_id = api.create_draft(project_name="MyVideo")
print(f"Created draft with ID: {draft_id}")
- Once run, CapCut will automatically generate a draft of a new project with an ID that will be used for subsequent operations.
- Ensure that the CapCut software is turned on, otherwise API calls may fail.
Add Material
CapCutAPI supports adding video, image and audio clips. Sample code:
api.add_material(draft_id, material_type="video", file_path="path/to/video.mp4")
api.add_material(draft_id, material_type="audio", file_path="path/to/audio.mp3")
material_type
be in favor of"video"
,"image"
cap (a poem)"audio"
The- The file path needs to be the absolute path of the local file.
- The clip is automatically added to the default track of the timeline, and the position can be adjusted by parameters.
Applying effects and transitions
CapCutAPI allows special effects and transitions to be applied automatically. For example, adding a fade transition:
api.apply_transition(draft_id, transition_type="fade", duration=1.0)
transition_type
A variety of effects are supported, such as"fade"
,"slide"
etc., see the documentation for a list.duration
The parameter controls the length of the transition (in seconds).
Automatic generation of subtitles
CapCutAPI integrates AI subtitle generation and requires configuration of an AI service key. Sample code:
api.generate_subtitles(draft_id, language="zh-CN", output_path="subtitles.srt")
language
The parameters support multiple languages, such as"zh-CN"
(in Chinese),"en-US"
(English).- Generated subtitle files are saved in the specified path, support for
.srt
cap (a poem).vtt
Format. - Clear video audio is recommended to improve captioning accuracy.
Export Video
After finishing editing, you can export the video without watermark:
api.export_video(draft_id, output_path="path/to/output.mp4", resolution="1080p")
resolution
be in favor of"720p"
,"1080p"
etc., depending on the CapCut version.- The export process may take a few minutes, depending on the length of the video.
caveat
- documentation reference: the project root directory's
README.md
cap (a poem)examples/
The folder contains detailed sample code, which is recommended to be read carefully when using it for the first time. - adjust components during testing: If you encounter an error while running the script, check that CapCut is running and that the network connection is working.
- compatibility: CapCutAPI mainly supports the desktop version of CapCut for Windows and macOS platforms, with limited mobile support.
- Community Support: If you have questions, file an issue on GitHub or check out the community discussion.
With these steps, users can quickly get started with CapCutAPI to automate video editing. Whether it's generating short videos in batch or handling complex editing tasks, the tool can significantly improve efficiency.
application scenario
- Mass production of short videos
Content creators need to quickly generate a large number of short videos (e.g., Jittery, Shutterbug content).CapCutAPI can automatically generate multiple videos by batch importing clips, adding subtitles and special effects through scripts, reducing the time of repetitive operations. - Educational video production
Teachers or training organizations need to create subtitled instructional videos for their courses, and CapCutAPI's AI subtitling feature automatically generates accurate subtitles with special effects to enhance the video's appeal. - Marketing Video Automation
Enterprises need to create promotional videos for their products. CapCutAPI supports quick import of branded footage and automatically applies unified effects and transitions for large-scale marketing campaigns. - Personal Project Clips
Indie developers or video enthusiasts can use CapCutAPI to write custom scripts to implement complex editing logic, such as dynamically adjusting the timeline or batch processing multiple clips.
QA
- Is there a fee for CapCutAPI?
CapCutAPI is a free open source project hosted on GitHub. However, some features (such as AI subtitles) may require CapCut Pro or a third-party AI service key, depending on the service provider. - Is CapCut supported on mobile?
Currently CapCutAPI supports mainly desktop versions of CapCut (Windows and macOS). Mobile support is limited, so we recommend checking the official documentation for the latest compatibility information. - How do I resolve API call failures?
Ensure that the CapCut software is running, check the network connection and API key configuration. If it still fails, submit an issue on the GitHub project page with an error log. - Is it possible to export watermark-free videos?
Yes, CapCutAPI supports exporting watermark-free videos, but make sure you are using CapCut Pro or meet the conditions for watermark-free export.