CapCutAPI (Open Source): Automate CapCut Editing + One-Click AI Subtitles

leo 08/09/2025

Control CapCut/剪映 programmatically—eliminate manual dragging and unleash the power of automation for developers!


1. Introduction

CapCutAPI is a powerful editing API that empowers you to take full control of your AI-generated assets, including images, audio, video, and text. It provides the precision needed to refine and customize raw AI output, such as adjusting video speed or mirroring an image. This capability effectively solves the lack of control often found in AI video generation, allowing you to easily transform your creative ideas into polished videos.

  • Creating drafts
  • Adding media assets (videos, audio, images, text, stickers)
  • Applying effects and animations
  • AI-generated subtitles
  • Remote API calls

GitHub Repository:
https://github.com/sun-guannan/CapCutAPI

《CapCutAPI (Open Source): Automate CapCut Editing + One-Click AI Subtitles》

2. Key Features

  • Draft Management: Create, read, modify, and save CapCut draft files for efficient batch processing.
  • Multi-type Media Support: Handle videos, audio, images, text, stickers, and more.
  • Rich Effects: Apply transitions, filters, masks, animations, and other effects via API calls.
  • HTTP API Service: RESTful interfaces for remote calls and integration into automated workflows.
  • AI Integration: Supports speech recognition for auto-generating subtitles and text content.
  • Cross-Platform Compatibility: Works with both Jianying (China) and CapCut (International) via configuration.

3. Tech Stack

ComponentDetails
LanguagePython (recommended 3.8.20)
DependenciesFFmpeg (for video processing)
API ModeRESTful HTTP interface, supporting both local and remote calls
Draft Format.draft folder structure (compatible with CapCut’s local draft format)
PlatformsWindows/macOS (Desktop versions of Jianying & CapCut)

4. Deployment & Setup (Official Steps)

✅ Prerequisites

  • Python 3.8.20
  • FFmpeg installed and accessible via command line

✅ Clone & Install Dependencies

bash

git clone https://github.com/sun-guannan/CapCutAPI.git
cd CapCutAPI
pip install -r requirements.txt

✅ Configure & Start the Service

bash

cp config.json.example config.json
# Edit config.json (e.g., port, CapCut version, AI service keys)
python capcut_server.py
  • Default port: 9000 (configurable in config.json)
  • Once started, use the API endpoints to operate.

5. Usage Examples

1. Create a Draft

python

import requests

res = requests.post("http://localhost:9000/create_draft")
draft_id = res.json().get("draft_id")
print("Draft ID:", draft_id)

2. Add Media

python

# Add video
requests.post("http://localhost:9000/add_video", json={
    "draft_id": draft_id,
    "video_url": "http://example.com/video.mp4",
    "start": 0, "end": 10,
    "width": 1080, "height": 1920
})

# Add text
requests.post("http://localhost:9000/add_text", json={
    "draft_id": draft_id,
    "text": "Hello, World!",
    "start": 0, "end": 3,
    "font": "ZY_Courage",
    "font_color": "#FF0000",
    "font_size": 30.0
})

3. Apply Effects & Subtitles

python

# Add effect
requests.post("http://localhost:9000/add_effect", json={
    "draft_id": draft_id,
    "effect": "fade",
    "duration": 1.0
})

# AI-generated subtitles (requires AI service config)
requests.post("http://localhost:9000/add_subtitle", json={
    "draft_id": draft_id,
    "language": "zh-CN"
})

4. Save Draft

python

requests.post("http://localhost:9000/save_draft", json={
    "draft_id": draft_id,
    "draft_folder": "Your_CapCut_Draft_Directory"
})
  • Saves as a dfd_* folder in the server directory.
  • Copy this folder to your local CapCut/Jianying drafts path to open in the software.

For more examples (audio, stickers, etc.), see example.py in the project.


6. Key API Endpoints

  • POST /create_draft → Create a draft
  • POST /add_video → Add video
  • POST /add_audio → Add audio
  • POST /add_image → Add image
  • POST /add_text → Add text
  • POST /add_subtitle → Add subtitle
  • POST /add_effect → Add effect
  • POST /add_sticker → Add sticker
  • POST /save_draft → Save draft

7. Use Cases

  • Batch Short Video Generation: E-commerce promos, course videos, social media content.
  • Auto-Subtitle Generation: AI speech-to-text for .srt/.vtt files to improve accessibility.
  • Template-Based Editing: Quickly apply intros, watermarks, transitions for consistent output.
  • Automation Integration: Seamlessly connect with CI/CD pipelines or content distribution systems.

💡 Tips & Recommendations

  • The project is under active development—check README.md and example.py for updates.
  • Ensure CapCut/Jianying is running and the network is stable if API calls fail.
  • Use the desktop version of CapCut for best compatibility (mobile support is limited).
  • Submit issues on GitHub or join community discussions for support.