1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# v1.animation
## Module Functions
### Animation <a name="create"></a>
Create a Animation video. The estimated frame cost is calculated based on the `fps` and `end_seconds` input.
**API Endpoint**: `POST /v1/animation`
#### Parameters
| Parameter | Required | Description | Example |
| --------------------- | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `assets` | ✓ | Provide the assets for animation. | `V1AnimationCreateBodyAssets {audio_file_path: Some("api-assets/id/1234.mp3".to_string()), audio_source: V1AnimationCreateBodyAssetsAudioSourceEnum::File, image_file_path: Some("api-assets/id/1234.png".to_string()), ..Default::default()}` |
| `└─ audio_file_path` | ✗ | The path of the input audio. This field is required if `audio_source` is `file`. 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.mp3".to_string()` |
| `└─ audio_source` | ✓ | Optionally add an audio source if you'd like to incorporate audio into your video | `V1AnimationCreateBodyAssetsAudioSourceEnum::File` |
| `└─ image_file_path` | ✗ | An initial image to use a the first frame of the video. 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.png".to_string()` |
| `└─ youtube_url` | ✗ | Using a youtube video as the input source. This field is required if `audio_source` is `youtube` | `"http://www.example.com".to_string()` |
| `end_seconds` | ✓ | This value determines the duration of the output video. | `5.0` |
| `fps` | ✓ | The desire output video frame rate | `12.0` |
| `height` | ✓ | The height of the final output video. The maximum height depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details | `512` |
| `style` | ✓ | Defines the style of the output video | `V1AnimationCreateBodyStyle {art_style: V1AnimationCreateBodyStyleArtStyleEnum::PainterlyIllustration, art_style_custom: Some("Watercolor painting with soft pastel colors".to_string()), camera_effect: V1AnimationCreateBodyStyleCameraEffectEnum::SimpleZoomIn, prompt: Some("Cyberpunk city".to_string()), prompt_type: V1AnimationCreateBodyStylePromptTypeEnum::Custom, transition_speed: 5}` |
| `└─ art_style` | ✓ | The art style used to create the output video | `V1AnimationCreateBodyStyleArtStyleEnum::PainterlyIllustration` |
| `└─ art_style_custom` | ✗ | Describe custom art style. This field is required if `art_style` is `Custom` | `"Watercolor painting with soft pastel colors".to_string()` |
| `└─ camera_effect` | ✓ | The camera effect used to create the output video | `V1AnimationCreateBodyStyleCameraEffectEnum::SimpleZoomIn` |
| `└─ prompt` | ✗ | The prompt used for the video. Prompt is required if `prompt_type` is `custom`. Otherwise this value is ignored | `"Cyberpunk city".to_string()` |
| `└─ prompt_type` | ✓ | * `custom` - Use your own prompt for the video. * `use_lyrics` - Use the lyrics of the audio to create the prompt. If this option is selected, then `assets.audio_source` must be `file` or `youtube`. * `ai_choose` - Let AI write the prompt. If this option is selected, then `assets.audio_source` must be `file` or `youtube`. | `V1AnimationCreateBodyStylePromptTypeEnum::Custom` |
| `└─ transition_speed` | ✓ | Change determines how quickly the video's content changes across frames. * Higher = more rapid transitions. * Lower = more stable visual experience. | `5` |
| `width` | ✓ | The width of the final output video. The maximum width depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details | `512` |
| `name` | ✗ | Give your video a custom name for easy identification. | `"My Animation video".to_string()` |
#### Example Snippet
```rust
let client = magic_hour::Client::default()
.with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
let res = client
.v1()
.animation()
.create(magic_hour::resources::v1::animation::CreateRequest {
assets: magic_hour::models::V1AnimationCreateBodyAssets {
audio_file_path: Some("api-assets/id/1234.mp3".to_string()),
audio_source: magic_hour::models::V1AnimationCreateBodyAssetsAudioSourceEnum::File,
image_file_path: Some("api-assets/id/1234.png".to_string()),
..Default::default()
},
end_seconds: 5.0,
fps: 12.0,
height: 512,
name: Some("My Animation video".to_string()),
style: magic_hour::models::V1AnimationCreateBodyStyle {
art_style: magic_hour::models::V1AnimationCreateBodyStyleArtStyleEnum::PainterlyIllustration,
art_style_custom: Some(
"Watercolor painting with soft pastel colors".to_string(),
),
camera_effect: magic_hour::models::V1AnimationCreateBodyStyleCameraEffectEnum::SimpleZoomIn,
prompt: Some("Cyberpunk city".to_string()),
prompt_type: magic_hour::models::V1AnimationCreateBodyStylePromptTypeEnum::Custom,
transition_speed: 5,
},
width: 512,
})
.await;
```
#### Response
##### Type
[V1AnimationCreateResponse](/src/models/v1_animation_create_response.rs)
##### Example
```rust
V1AnimationCreateResponse {credits_charged: 450, estimated_frame_cost: 123, id: "cuid-example".to_string()}
```