AIcut Video Editing Skill
This skill helps understand and manipulate the AIcut video editing system.
Core Concepts
Project Structure
- Project Snapshot:
ai_workspace/project-snapshot.json - The single source of truth for timeline state.
- Project Folders:
projects/<display-name>/ - Readable folder names mapped to internal IDs via projects/projectIdMap.json.
- Assets:
projects/<display-name>/assets/ - Media files organized by type.
- Exports:
exports/ - Final rendered videos.
Project Management
1. UI Creation & Management
- Create: Click "New Project" in the
/projects page.
- View: Browse existing projects in the UI list. The UI synchronizes with the filesystem in real-time.
- Delete: Click the Delete icon on a project card. This removes the project from the UI and deletes its folder from the
projects/ directory.
2. Programmatic Lifecycle (New/Switch/Delete Project Logic)
To manage projects via API/Python:
- Initialize: Call
switch_project(projectId). If the project is loaded for the first time, it creates the folder. If it exists, the UI will automatically jump to that project.
- Archiving (Readable Folders): Use
archive_project(). The system uses the project's name as the folder name.
- Switching: Call
switch_project(anotherId). The UI will perform a hot-reload and navigate to the new project editor.
- Mapping: Folder names are mapped to internal IDs in
projectIdMap.json.
- Deletion: Call
delete_project(projectId) to permanently remove the project folder and its ID mapping.
Element Types
1. Media Element (Video/Image/Audio)
{
"id": "e.g., el-0",
"type": "media",
"mediaId": "asset-reference-id",
"name": "display-name.mp4",
"thumbnailUrl": "/api/media/serve?path=...", // CRITICAL for video/image preview
"startTime": 0.0, // In seconds
"duration": 5.0, // Visible duration
"trimStart": 0.0, // Crop from start of source
"trimEnd": 0.0, // Crop from end of source
"x": 960, "y": 540, // Postion (Center origin is 960, 540)
"scale": 1.0,
"opacity": 1.0,
"volume": 1.0,
"metadata": {
"importSource": "sdk_v2"
}
}
2. Text/Subtitle Element
To ensure compatibility between Python and Frontend, use this format:
{
"id": "unique-id",
"type": "text",
"content": "The display text", // Primary text field
"startTime": 0.0,
"duration": 3.0,
"trimStart": 0, "trimEnd": 0, // MUST include (default to 0)
"x": 960, "y": 900, // Subtitle position (bottom center)
"rotation": 0, "opacity": 1, // MUST include defaults
"fontSize": 60, // Styles MUST be at top level
"fontFamily": "Arial",
"color": "#ffffff",
"textAlign": "center",
"fontWeight": "bold",
"style": { // Optional nested style for Python SDK
"fontSize": 60,
"color": "#ffffff"
}
}
Data Schema Rules (The "Contract")
- Primary Text Field: Use
content as the single source of truth for text. The name field is OMITTED for text elements to prevent redundancy.
- Flattened Styles: While Python SDK uses a style object, the frontend requires fontSize, color, etc., at the top level of the element.
- Implicit Defaults: Never skip
trimStart, trimEnd, rotation, and opacity. If missing, the frontend might fail to render or default to 0 (invisible).
- Coordinate System: origin
(0,0) is Top-Left. 1920x1080 canvas. Standard center is (960, 540).
- IDs: IDs must be unique strings (e.g.,
nanoid or sub-0, sub-1).
Common Operations
Adding Media
Preferred Method: Use AIcut SDK (import_media).
The SDK automates the following steps:
- Thumbnail Generation: Calls
/api/media/generate-thumbnail for videos to create high-quality frames.
- Asset Creation: Automatically calculates IDs and creates an asset entry with a stable serve URL.
- Element Placement: Adds the element to the timeline with the correct
thumbnailUrl.
Manual Method (Advanced):
- Create an asset entry in the
assets array.
- Create an element in a track referencing the asset's
id.
- MUST set
thumbnailUrl (use the asset's URL or a dedicated JPG thumb) for visual feedback.
Creating Subtitles
- Create or use an existing text track (type:
text).
- Add text elements according to the Text Element Schema above.
- Synchronize
startTime with audio assets.
Modifying Volume
- Set
element.volume (0.0 = mute, 1.0 = normal, up to 10.0 = 1000%).
API Integration
The frontend exposes a state-syncing API at POST /api/ai-edit. Always prefer using the Python SDK (scripts/aicut_sdk.py) over raw HTTP requests.
Supported Actions (POST)
| Action |
Description |
Key Data Fields |
addSubtitle |
Add a single subtitle |
text, startTime, duration, fontSize, color |
addMultipleSubtitles |
Batch add subtitles |
subtitles (Array of subtitle objects) |
clearSubtitles |
Remove subtitles |
startTime, duration (Optional range) |
switchProject |
Load or create project |
projectId |
archiveProject |
Save workspace to disk |
projectId (Optional) |
deleteProject |
Delete project folder |
projectId |
updateSnapshot |
Push full timeline state |
project, tracks, assets (Full JSON object) |
Media Utilities
GET /api/media/serve?path=<encoded_absolute_path>: Serves local files as browser-accessible URLs.
POST /api/media/generate-thumbnail: Generate a JPG from a video file (Body: { filePath: string }).
Snapshot & Project Endpoints
GET /api/ai-edit?action=getSnapshot: Retrieve current timeline state.
GET /api/ai-edit?action=listProjects: List all archived projects.
GET /api/ai-edit?action=poll: Polled by frontend to fetch pending edits.
Best Practices
- Avoid
curl on Windows: Use a temporary Python script or the AIcut SDK for stable JSON communication.
- Paths: DO NOT use
/materials/ relative paths. Always use absolute paths wrapped in the /api/media/serve?path= API. This ensures files from any drive (F:, D:, etc.) work correctly.
- Atomic Updates: Read the full snapshot, modify your slice, then write the full snapshot back.
- Validation: Ensure all numeric fields are
number type, not string.
- Layering: Text tracks should remain at the top (lower array index) to be visible over media.
- SDK First: Always use
scripts/aicut_sdk.py. It correctly handles thumbnail generation calls and internal path mapping.
Executable Scripts
The following scripts/CLIs are available in the scripts/ directory:
| Tool |
Purpose |
Usage Example |
aicut_tool.py |
Centralized CLI for all common tasks. |
python scripts/aicut_tool.py media import "path/to/video.mp4" |
aicut_sdk.py |
Core library for all programmatic edits. |
from aicut_sdk import AIcutClient |
fix_subtitle_pos.py |
Align subtitles to bottom center. |
python scripts/fix_subtitle_pos.py |
project_manager.py |
Standalone project lifecycle tool (legacy support) |
python scripts/project_manager.py list |
Note: These scripts depend on scripts/aicut_sdk.py. Ensure you run them from the skill directory or add the directory to your PYTHONPATH.
1---2name: aicut-editing3description: 指导如何进行项目管理(新建、查看、切换、删除)、操作 AIcut 时间轴、添加媒体、创建字幕及导出视频。当用户询问关于项目列表管理、新建/切换/删除项目、视频剪辑、时间轴操作、添加素材、生成的视频有问题或媒体管理时使用此技能。4---56# AIcut Video Editing Skill78This skill helps understand and manipulate the AIcut video editing system.910## Core Concepts1112### Project Structure13- **Project Snapshot**: `ai_workspace/project-snapshot.json` - The single source of truth for timeline state.14- **Project Folders**: `projects/<display-name>/` - Readable folder names mapped to internal IDs via `projects/projectIdMap.json`.15- **Assets**: `projects/<display-name>/assets/` - Media files organized by type.16- **Exports**: `exports/` - Final rendered videos.1718### Project Management1920#### 1. UI Creation & Management21- **Create**: Click **"New Project"** in the `/projects` page.22- **View**: Browse existing projects in the UI list. The UI synchronizes with the filesystem in real-time.23- **Delete**: Click the **Delete** icon on a project card. This removes the project from the UI and deletes its folder from the `projects/` directory.2425#### 2. Programmatic Lifecycle (New/Switch/Delete Project Logic)26To manage projects via API/Python:271. **Initialize**: Call `switch_project(projectId)`. If the project is loaded for the first time, it creates the folder. If it exists, the UI will automatically jump to that project.282. **Archiving (Readable Folders)**: Use `archive_project()`. The system uses the project's **name** as the folder name.293. **Switching**: Call `switch_project(anotherId)`. The UI will perform a hot-reload and navigate to the new project editor.304. **Mapping**: Folder names are mapped to internal IDs in `projectIdMap.json`.315. **Deletion**: Call `delete_project(projectId)` to permanently remove the project folder and its ID mapping.3233### Element Types3435#### 1. Media Element (Video/Image/Audio)36```json37{38 "id": "e.g., el-0",39 "type": "media",40 "mediaId": "asset-reference-id",41 "name": "display-name.mp4",42 "thumbnailUrl": "/api/media/serve?path=...", // CRITICAL for video/image preview43 "startTime": 0.0, // In seconds44 "duration": 5.0, // Visible duration45 "trimStart": 0.0, // Crop from start of source46 "trimEnd": 0.0, // Crop from end of source47 "x": 960, "y": 540, // Postion (Center origin is 960, 540)48 "scale": 1.0, 49 "opacity": 1.0,50 "volume": 1.0,51 "metadata": {52 "importSource": "sdk_v2" 53 }54}55```5657#### 2. Text/Subtitle Element58To ensure compatibility between Python and Frontend, use this format:59```json60{61 "id": "unique-id",62 "type": "text",63 "content": "The display text", // Primary text field64 "startTime": 0.0,65 "duration": 3.0,66 "trimStart": 0, "trimEnd": 0, // MUST include (default to 0)67 "x": 960, "y": 900, // Subtitle position (bottom center)68 "rotation": 0, "opacity": 1, // MUST include defaults69 "fontSize": 60, // Styles MUST be at top level70 "fontFamily": "Arial", 71 "color": "#ffffff",72 "textAlign": "center",73 "fontWeight": "bold",74 "style": { // Optional nested style for Python SDK75 "fontSize": 60,76 "color": "#ffffff"77 }78}79```8081## Data Schema Rules (The "Contract")82831. **Primary Text Field**: Use `content` as the single source of truth for text. The `name` field is OMITTED for text elements to prevent redundancy.842. **Flattened Styles**: While Python SDK uses a style object, the frontend requires fontSize, color, etc., at the top level of the element.853. **Implicit Defaults**: Never skip `trimStart`, `trimEnd`, `rotation`, and `opacity`. If missing, the frontend might fail to render or default to 0 (invisible).864. **Coordinate System**: origin `(0,0)` is Top-Left. 1920x1080 canvas. Standard center is `(960, 540)`.875. **IDs**: IDs must be unique strings (e.g., `nanoid` or `sub-0`, `sub-1`).8889## Common Operations9091### Adding Media92**Preferred Method: Use AIcut SDK (`import_media`).**93The SDK automates the following steps:941. **Thumbnail Generation**: Calls `/api/media/generate-thumbnail` for videos to create high-quality frames.952. **Asset Creation**: Automatically calculates IDs and creates an asset entry with a stable serve URL.963. **Element Placement**: Adds the element to the timeline with the correct `thumbnailUrl`.9798**Manual Method (Advanced):**991. Create an asset entry in the `assets` array.1002. Create an element in a track referencing the asset's `id`.1013. **MUST** set `thumbnailUrl` (use the asset's URL or a dedicated JPG thumb) for visual feedback.102103### Creating Subtitles1041. Create or use an existing text track (type: `text`).1052. Add text elements according to the **Text Element Schema** above.1063. Synchronize `startTime` with audio assets.107108### Modifying Volume109- Set `element.volume` (0.0 = mute, 1.0 = normal, up to 10.0 = 1000%).110111## API Integration112113The frontend exposes a state-syncing API at `POST /api/ai-edit`. **Always prefer using the Python SDK (`scripts/aicut_sdk.py`) over raw HTTP requests.**114115### Supported Actions (POST)116117| Action | Description | Key Data Fields |118| :--------------------- | :----------------------- | :--------------------------------------------------- |119| `addSubtitle` | Add a single subtitle | `text`, `startTime`, `duration`, `fontSize`, `color` |120| `addMultipleSubtitles` | Batch add subtitles | `subtitles` (Array of subtitle objects) |121| `clearSubtitles` | Remove subtitles | `startTime`, `duration` (Optional range) |122| `switchProject` | Load or create project | `projectId` |123| `archiveProject` | Save workspace to disk | `projectId` (Optional) |124| `deleteProject` | Delete project folder | `projectId` |125| `updateSnapshot` | Push full timeline state | `project`, `tracks`, `assets` (Full JSON object) |126127### Media Utilities128- `GET /api/media/serve?path=<encoded_absolute_path>`: Serves local files as browser-accessible URLs.129- `POST /api/media/generate-thumbnail`: Generate a JPG from a video file (Body: `{ filePath: string }`).130131### Snapshot & Project Endpoints132- `GET /api/ai-edit?action=getSnapshot`: Retrieve current timeline state.133- `GET /api/ai-edit?action=listProjects`: List all archived projects.134- `GET /api/ai-edit?action=poll`: Polled by frontend to fetch pending edits.135136## Best Practices1371381. **Avoid `curl` on Windows**: Use a temporary Python script or the AIcut SDK for stable JSON communication.1392. **Paths**: **DO NOT** use `/materials/` relative paths. **Always use absolute paths** wrapped in the `/api/media/serve?path=` API. This ensures files from any drive (F:, D:, etc.) work correctly.1403. **Atomic Updates**: Read the full snapshot, modify your slice, then write the full snapshot back.1414. **Validation**: Ensure all numeric fields are `number` type, not `string`.1425. **Layering**: Text tracks should remain at the top (lower array index) to be visible over media.1436. **SDK First**: Always use `scripts/aicut_sdk.py`. It correctly handles thumbnail generation calls and internal path mapping.144145## Executable Scripts146147The following scripts/CLIs are available in the `scripts/` directory:148149| Tool | Purpose | Usage Example |150| --------------------- | -------------------------------------------------- | --------------------------------------------------------------- |151| `aicut_tool.py` | **Centralized CLI** for all common tasks. | `python scripts/aicut_tool.py media import "path/to/video.mp4"` |152| `aicut_sdk.py` | Core library for all programmatic edits. | `from aicut_sdk import AIcutClient` |153| `fix_subtitle_pos.py` | Align subtitles to bottom center. | `python scripts/fix_subtitle_pos.py` |154| `project_manager.py` | Standalone project lifecycle tool (legacy support) | `python scripts/project_manager.py list` |155156> **Note**: These scripts depend on `scripts/aicut_sdk.py`. Ensure you run them from the skill directory or add the directory to your `PYTHONPATH`.