Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 89 additions & 1 deletion .sdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "08756a67-c9aa-401d-9e38-feee98a19df4",
"id": "6058b2ba-30f8-46d6-9c9d-83938cbf7071",
"tracked_paths": [
{
"editable": true,
Expand Down Expand Up @@ -209,6 +209,22 @@
"editable": true,
"path": "src/resources/v1/ai-talking-photo/resource-client.ts"
},
{
"editable": true,
"path": "src/resources/v1/ai-video-editor/README.md"
},
{
"editable": true,
"path": "src/resources/v1/ai-video-editor/index.ts"
},
{
"editable": false,
"path": "src/resources/v1/ai-video-editor/request-types.ts"
},
{
"editable": true,
"path": "src/resources/v1/ai-video-editor/resource-client.ts"
},
{
"editable": true,
"path": "src/resources/v1/ai-voice-cloner/README.md"
Expand Down Expand Up @@ -321,6 +337,22 @@
"editable": true,
"path": "src/resources/v1/body-swap/resource-client.ts"
},
{
"editable": true,
"path": "src/resources/v1/character-replace/README.md"
},
{
"editable": true,
"path": "src/resources/v1/character-replace/index.ts"
},
{
"editable": false,
"path": "src/resources/v1/character-replace/request-types.ts"
},
{
"editable": true,
"path": "src/resources/v1/character-replace/resource-client.ts"
},
{
"editable": true,
"path": "src/resources/v1/face-detection/README.md"
Expand Down Expand Up @@ -765,6 +797,22 @@
"editable": false,
"path": "src/types/v1-ai-talking-photo-create-response.ts"
},
{
"editable": false,
"path": "src/types/v1-ai-video-editor-create-body-assets.ts"
},
{
"editable": false,
"path": "src/types/v1-ai-video-editor-create-body-style.ts"
},
{
"editable": false,
"path": "src/types/v1-ai-video-editor-create-body.ts"
},
{
"editable": false,
"path": "src/types/v1-ai-video-editor-create-response.ts"
},
{
"editable": false,
"path": "src/types/v1-ai-voice-cloner-create-body-assets.ts"
Expand Down Expand Up @@ -905,6 +953,38 @@
"editable": false,
"path": "src/types/v1-body-swap-create-response.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-assets.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-resolution-enum.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-style-mode-enum.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-style-points-item.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-style-selection-mode-enum.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body-style.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-body.ts"
},
{
"editable": false,
"path": "src/types/v1-character-replace-create-response.ts"
},
{
"editable": false,
"path": "src/types/v1-face-detection-create-body-assets.ts"
Expand Down Expand Up @@ -1237,6 +1317,10 @@
"editable": false,
"path": "test/v1-ai-talking-photo.test.ts"
},
{
"editable": false,
"path": "test/v1-ai-video-editor.test.ts"
},
{
"editable": false,
"path": "test/v1-ai-voice-cloner.test.ts"
Expand Down Expand Up @@ -1265,6 +1349,10 @@
"editable": false,
"path": "test/v1-body-swap.test.ts"
},
{
"editable": false,
"path": "test/v1-character-replace.test.ts"
},
{
"editable": false,
"path": "test/v1-face-detection.test.ts"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
- [create](src/resources/v1/ai-talking-photo/README.md#create) - AI Talking Photo
- [generate](src/resources/v1/ai-talking-photo/README.md#generate) - AI Talking Photo Generate Workflow

### [v1.aiVideoEditor](src/resources/v1/ai-video-editor/README.md)

- [create](src/resources/v1/ai-video-editor/README.md#create) - AI Video Editor
- [generate](src/resources/v1/ai-video-editor/README.md#generate) - AI Video Editor Generate Workflow

### [v1.aiVoiceCloner](src/resources/v1/ai-voice-cloner/README.md)

- [create](src/resources/v1/ai-voice-cloner/README.md#create) - AI Voice Cloner
Expand Down Expand Up @@ -287,6 +292,11 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
- [create](src/resources/v1/body-swap/README.md#create) - Body Swap
- [generate](src/resources/v1/body-swap/README.md#generate) - Body Swap Generate Workflow

### [v1.characterReplace](src/resources/v1/character-replace/README.md)

- [create](src/resources/v1/character-replace/README.md#create) - Character Replace
- [generate](src/resources/v1/character-replace/README.md#generate) - Character Replace Generate Workflow

### [v1.faceDetection](src/resources/v1/face-detection/README.md)

- [create](src/resources/v1/face-detection/README.md#create) - Face Detection
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magic-hour",
"version": "0.67.0",
"version": "0.68.0",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down
2 changes: 2 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
- [ai-meme-generator](resources/v1/ai-meme-generator/README.md) - ai-meme-generator
- [ai-qr-code-generator](resources/v1/ai-qr-code-generator/README.md) - ai-qr-code-generator
- [ai-talking-photo](resources/v1/ai-talking-photo/README.md) - ai-talking-photo
- [ai-video-editor](resources/v1/ai-video-editor/README.md) - ai-video-editor
- [ai-voice-cloner](resources/v1/ai-voice-cloner/README.md) - ai-voice-cloner
- [ai-voice-generator](resources/v1/ai-voice-generator/README.md) - ai-voice-generator
- [animation](resources/v1/animation/README.md) - animation
- [audio-projects](resources/v1/audio-projects/README.md) - audio-projects
- [audio-to-video](resources/v1/audio-to-video/README.md) - audio-to-video
- [auto-subtitle-generator](resources/v1/auto-subtitle-generator/README.md) - auto-subtitle-generator
- [body-swap](resources/v1/body-swap/README.md) - body-swap
- [character-replace](resources/v1/character-replace/README.md) - character-replace
- [face-detection](resources/v1/face-detection/README.md) - face-detection
- [face-swap-photo](resources/v1/face-swap-photo/README.md) - face-swap-photo
- [face-swap](resources/v1/face-swap/README.md) - face-swap
Expand Down
2 changes: 1 addition & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum Environment {
Environment = "https://api.magichour.ai",
MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.68.0",
MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.69.0",
}
2 changes: 2 additions & 0 deletions src/resources/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
- [ai-meme-generator](ai-meme-generator/README.md) - ai-meme-generator
- [ai-qr-code-generator](ai-qr-code-generator/README.md) - ai-qr-code-generator
- [ai-talking-photo](ai-talking-photo/README.md) - ai-talking-photo
- [ai-video-editor](ai-video-editor/README.md) - ai-video-editor
- [ai-voice-cloner](ai-voice-cloner/README.md) - ai-voice-cloner
- [ai-voice-generator](ai-voice-generator/README.md) - ai-voice-generator
- [animation](animation/README.md) - animation
- [audio-projects](audio-projects/README.md) - audio-projects
- [audio-to-video](audio-to-video/README.md) - audio-to-video
- [auto-subtitle-generator](auto-subtitle-generator/README.md) - auto-subtitle-generator
- [body-swap](body-swap/README.md) - body-swap
- [character-replace](character-replace/README.md) - character-replace
- [face-detection](face-detection/README.md) - face-detection
- [face-swap](face-swap/README.md) - face-swap
- [face-swap-photo](face-swap-photo/README.md) - face-swap-photo
Expand Down
118 changes: 118 additions & 0 deletions src/resources/v1/ai-video-editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# v1.ai-video-editor

## Module Functions

<!-- CUSTOM DOCS START -->

### AI Video Editor Generate Workflow <a name="generate"></a>

The workflow performs the following action

1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
2. trigger a generation
3. poll for a completion status. This is configurable
4. if success, download the output to local directory

> [!TIP]
> This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.

#### Parameters

In addition to the parameters listed in the `create` section below, `generate` introduces 3 new parameters:

- `waitForCompletion` (boolean, default true): Whether to wait for the project to complete.
- `downloadOutputs` (boolean, default true): Whether to download the generated files
- `downloadDirectory` (string, optional): Directory to save downloaded files (defaults to current directory)

#### Example Snippet

```typescript
import { Client } from "magic-hour";

const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiVideoEditor.generate(
{
assets: { videoFilePath: "/path/to/1234.mp4" },
endSeconds: 5.0,
name: "My Video Editor video",
startSeconds: 0.0,
style: { prompt: "Change the car color to blue" },
},
{
waitForCompletion: true,
downloadOutputs: true,
downloadDirectory: ".",
},
);
```

<!-- CUSTOM DOCS END -->

### AI Video Editor <a name="create"></a>

**What this API does**

Create the same Video Editor you can make in the browser, but programmatically, so you can automate it, run it at scale, or connect it to your own app or workflow.

**Good for**

- Automation and batch processing
- Adding video editor into apps, pipelines, or tools

**How it works (3 steps)**

1. Upload your inputs (video, image, or audio) with [Generate Upload URLs](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls) and copy the `file_path`.
2. Send a request to create a video editor job with the basic fields.
3. Check the job status until it's `complete`, then download the result from `downloads`.

**Key options**

- Inputs: usually a file, sometimes a YouTube link, depending on project type
- Resolution: free users are limited to 576px; higher plans unlock HD and larger sizes
- Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt

**Cost**\
Credits are only charged for the frames that actually render. You'll see an estimate when the job is queued, and the final total after it's done.

For detailed examples, see the [product page](https://magichour.ai/products/video-editor).

**API Endpoint**: `POST /v1/ai-video-editor`

#### Parameters

| Parameter | Required | Description | Example |
| ------------------ | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
| `assets` | ✓ | Provide the assets for video editing. | `{"videoFilePath": "api-assets/id/1234.mp4"}` |
| `└─ videoFilePath` | ✓ | The video to edit. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details. | `"api-assets/id/1234.mp4"` |
| `endSeconds` | ✓ | End time of your clip in seconds. Must be greater than `start_seconds`. Duration must be between 3 and 10 seconds. | `5.0` |
| `style` | ✓ | | `{"prompt": "Change the car color to blue"}` |
| `└─ prompt` | ✓ | The prompt used to edit the video. | `"Change the car color to blue"` |
| `name` | ✗ | Give your video a custom name for easy identification. | `"My Video Editor video"` |
| `startSeconds` | ✗ | Start time of your clip (seconds). Must be ≥ 0. | `0.0` |

#### Example Snippet

```typescript
import { Client } from "magic-hour";

const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiVideoEditor.create({
assets: { videoFilePath: "api-assets/id/1234.mp4" },
endSeconds: 5.0,
name: "My Video Editor video",
startSeconds: 0.0,
style: { prompt: "Change the car color to blue" },
});
```

#### Response

##### Type

[V1AiVideoEditorCreateResponse](/src/types/v1-ai-video-editor-create-response.ts)

##### Example

```typescript
{"creditsCharged": 450, "estimatedFrameCost": 450, "id": "cuid-example"}
```
2 changes: 2 additions & 0 deletions src/resources/v1/ai-video-editor/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { CreateRequest } from "./request-types";
export { AiVideoEditorClient } from "./resource-client";
Loading
Loading