magic_hour 0.9.5__py3-none-any.whl → 0.44.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- magic_hour/README.md +34 -0
- magic_hour/__init__.py +1 -1
- magic_hour/client.py +8 -17
- magic_hour/environment.py +13 -1
- magic_hour/helpers/__init__.py +4 -0
- magic_hour/helpers/download.py +77 -0
- magic_hour/helpers/logger.py +8 -0
- magic_hour/resources/v1/README.md +32 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
- magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
- magic_hour/resources/v1/ai_face_editor/README.md +195 -0
- magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_face_editor/client.py +324 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
- magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
- magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
- magic_hour/resources/v1/ai_image_editor/README.md +125 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +290 -0
- magic_hour/resources/v1/ai_image_generator/README.md +99 -5
- magic_hour/resources/v1/ai_image_generator/client.py +170 -24
- magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
- magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
- magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
- magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
- magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
- magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
- magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
- magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
- magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
- magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
- magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
- magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
- magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
- magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
- magic_hour/resources/v1/animation/README.md +128 -6
- magic_hour/resources/v1/animation/client.py +247 -22
- magic_hour/resources/v1/audio_projects/README.md +135 -0
- magic_hour/resources/v1/audio_projects/__init__.py +12 -0
- magic_hour/resources/v1/audio_projects/client.py +310 -0
- magic_hour/resources/v1/audio_projects/client_test.py +520 -0
- magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
- magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
- magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
- magic_hour/resources/v1/client.py +75 -1
- magic_hour/resources/v1/face_detection/README.md +157 -0
- magic_hour/resources/v1/face_detection/__init__.py +12 -0
- magic_hour/resources/v1/face_detection/client.py +380 -0
- magic_hour/resources/v1/face_swap/README.md +137 -9
- magic_hour/resources/v1/face_swap/client.py +329 -38
- magic_hour/resources/v1/face_swap_photo/README.md +118 -3
- magic_hour/resources/v1/face_swap_photo/client.py +199 -14
- magic_hour/resources/v1/files/README.md +39 -0
- magic_hour/resources/v1/files/client.py +351 -1
- magic_hour/resources/v1/files/client_test.py +414 -0
- magic_hour/resources/v1/files/upload_urls/README.md +38 -17
- magic_hour/resources/v1/files/upload_urls/client.py +38 -34
- magic_hour/resources/v1/image_background_remover/README.md +96 -5
- magic_hour/resources/v1/image_background_remover/client.py +151 -16
- magic_hour/resources/v1/image_projects/README.md +82 -10
- magic_hour/resources/v1/image_projects/__init__.py +10 -2
- magic_hour/resources/v1/image_projects/client.py +154 -16
- magic_hour/resources/v1/image_projects/client_test.py +527 -0
- magic_hour/resources/v1/image_to_video/README.md +96 -11
- magic_hour/resources/v1/image_to_video/client.py +282 -38
- magic_hour/resources/v1/lip_sync/README.md +112 -9
- magic_hour/resources/v1/lip_sync/client.py +288 -34
- magic_hour/resources/v1/photo_colorizer/README.md +107 -0
- magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
- magic_hour/resources/v1/photo_colorizer/client.py +248 -0
- magic_hour/resources/v1/text_to_video/README.md +96 -7
- magic_hour/resources/v1/text_to_video/client.py +204 -18
- magic_hour/resources/v1/video_projects/README.md +81 -9
- magic_hour/resources/v1/video_projects/__init__.py +10 -2
- magic_hour/resources/v1/video_projects/client.py +151 -14
- magic_hour/resources/v1/video_projects/client_test.py +527 -0
- magic_hour/resources/v1/video_to_video/README.md +119 -15
- magic_hour/resources/v1/video_to_video/client.py +299 -46
- magic_hour/types/models/__init__.py +92 -56
- magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
- magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
- magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
- magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
- magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
- magic_hour/types/models/v1_animation_create_response.py +35 -0
- magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
- magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
- magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
- magic_hour/types/models/v1_face_detection_create_response.py +25 -0
- magic_hour/types/models/v1_face_detection_get_response.py +45 -0
- magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
- magic_hour/types/models/v1_face_swap_create_response.py +35 -0
- magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
- magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
- magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
- magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
- magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
- magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
- magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
- magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
- magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
- magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
- magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
- magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
- magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
- magic_hour/types/params/__init__.py +422 -176
- magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
- magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
- magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
- magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
- magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
- magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
- magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
- magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
- magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
- magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
- magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
- magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
- magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
- magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
- magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
- magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_detection_create_body.py +44 -0
- magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
- magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_swap_create_body.py +92 -0
- magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
- magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
- magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
- magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
- magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
- magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
- magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
- magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
- magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
- magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
- magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
- magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
- magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
- magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
- magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
- magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
- magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
- magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
- magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
- magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
- magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
- magic_hour-0.44.0.dist-info/METADATA +328 -0
- magic_hour-0.44.0.dist-info/RECORD +231 -0
- magic_hour/core/__init__.py +0 -52
- magic_hour/core/api_error.py +0 -56
- magic_hour/core/auth.py +0 -314
- magic_hour/core/base_client.py +0 -618
- magic_hour/core/binary_response.py +0 -23
- magic_hour/core/query.py +0 -106
- magic_hour/core/request.py +0 -156
- magic_hour/core/response.py +0 -293
- magic_hour/core/type_utils.py +0 -28
- magic_hour/core/utils.py +0 -55
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
- magic_hour/types/models/post_v1_animation_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_response.py +0 -25
- magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
- magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
- magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
- magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
- magic_hour/types/params/post_v1_face_swap_body.py +0 -72
- magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
- magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
- magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
- magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
- magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
- magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
- magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
- magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
- magic_hour-0.9.5.dist-info/METADATA +0 -133
- magic_hour-0.9.5.dist-info/RECORD +0 -132
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
|
@@ -1,14 +1,112 @@
|
|
|
1
|
+
# v1.video_to_video
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
## Module Functions
|
|
4
|
+
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Video To Video Generate Workflow <a name="generate"></a>
|
|
8
|
+
|
|
9
|
+
The workflow performs the following action
|
|
10
|
+
|
|
11
|
+
1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
|
|
12
|
+
2. trigger a generation
|
|
13
|
+
3. poll for a completion status. This is configurable
|
|
14
|
+
4. if success, download the output to local directory
|
|
15
|
+
|
|
16
|
+
> [!TIP]
|
|
17
|
+
> This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
|
|
18
|
+
|
|
19
|
+
#### Parameters
|
|
20
|
+
|
|
21
|
+
In Additional to the parameters listed in the `.create` section below, `.generate` introduces 3 new parameters:
|
|
22
|
+
|
|
23
|
+
- `wait_for_completion` (bool, default True): Whether to wait for the project to complete.
|
|
24
|
+
- `download_outputs` (bool, default True): Whether to download the generated files
|
|
25
|
+
- `download_directory` (str, optional): Directory to save downloaded files (defaults to current directory)
|
|
26
|
+
|
|
27
|
+
#### Synchronous Client
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from magic_hour import Client
|
|
31
|
+
from os import getenv
|
|
32
|
+
|
|
33
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
34
|
+
res = client.v1.video_to_video.generate(
|
|
35
|
+
assets={"video_file_path": "/path/to/1234.mp4", "video_source": "file"},
|
|
36
|
+
end_seconds=15.0,
|
|
37
|
+
start_seconds=0.0,
|
|
38
|
+
style={
|
|
39
|
+
"art_style": "3D Render",
|
|
40
|
+
"model": "default",
|
|
41
|
+
"prompt": "string",
|
|
42
|
+
"prompt_type": "default",
|
|
43
|
+
"version": "default",
|
|
44
|
+
},
|
|
45
|
+
fps_resolution="HALF",
|
|
46
|
+
name="Video To Video video",
|
|
47
|
+
wait_for_completion=True,
|
|
48
|
+
download_outputs=True,
|
|
49
|
+
download_directory="outputs"
|
|
50
|
+
)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Asynchronous Client
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from magic_hour import AsyncClient
|
|
57
|
+
from os import getenv
|
|
58
|
+
|
|
59
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
60
|
+
res = await client.v1.video_to_video.generate(
|
|
61
|
+
assets={"video_file_path": "/path/to/1234.mp4", "video_source": "file"},
|
|
62
|
+
end_seconds=15.0,
|
|
63
|
+
start_seconds=0.0,
|
|
64
|
+
style={
|
|
65
|
+
"art_style": "3D Render",
|
|
66
|
+
"model": "default",
|
|
67
|
+
"prompt": "string",
|
|
68
|
+
"prompt_type": "default",
|
|
69
|
+
"version": "default",
|
|
70
|
+
},
|
|
71
|
+
fps_resolution="HALF",
|
|
72
|
+
name="Video To Video video",
|
|
73
|
+
wait_for_completion=True,
|
|
74
|
+
download_outputs=True,
|
|
75
|
+
download_directory="outputs"
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<!-- CUSTOM DOCS END -->
|
|
80
|
+
|
|
81
|
+
### Video-to-Video <a name="create"></a>
|
|
4
82
|
|
|
5
83
|
Create a Video To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
6
|
-
|
|
7
|
-
Get more information about this mode at our [product page](/products/video-to-video).
|
|
8
|
-
|
|
84
|
+
|
|
85
|
+
Get more information about this mode at our [product page](https://magichour.ai/products/video-to-video).
|
|
9
86
|
|
|
10
87
|
**API Endpoint**: `POST /v1/video-to-video`
|
|
11
88
|
|
|
89
|
+
#### Parameters
|
|
90
|
+
|
|
91
|
+
| Parameter | Required | Deprecated | Description | Example |
|
|
92
|
+
| -------------------- | :------: | :--------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
|
|
93
|
+
| `assets` | ✓ | ✗ | Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used | `{"video_file_path": "api-assets/id/1234.mp4", "video_source": "file"}` |
|
|
94
|
+
| `└─ video_file_path` | ✗ | — | Required if `video_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). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/1234.mp4"` |
|
|
95
|
+
| `└─ video_source` | ✓ | — | | `"file"` |
|
|
96
|
+
| `└─ youtube_url` | ✗ | — | Using a youtube video as the input source. This field is required if `video_source` is `youtube` | `"http://www.example.com"` |
|
|
97
|
+
| `end_seconds` | ✓ | ✗ | The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds. | `15.0` |
|
|
98
|
+
| `start_seconds` | ✓ | ✗ | The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0. | `0.0` |
|
|
99
|
+
| `style` | ✓ | ✗ | | `{"art_style": "3D Render", "model": "default", "prompt_type": "default", "version": "default"}` |
|
|
100
|
+
| `└─ art_style` | ✓ | — | | `"3D Render"` |
|
|
101
|
+
| `└─ model` | ✗ | — | * `Dreamshaper` - a good all-around model that works for both animations as well as realism. * `Absolute Reality` - better at realism, but you'll often get similar results with Dreamshaper as well. * `Flat 2D Anime` - best for a flat illustration style that's common in most anime. * `default` - use the default recommended model for the selected art style. | `"default"` |
|
|
102
|
+
| `└─ prompt` | ✗ | — | The prompt used for the video. Prompt is required if `prompt_type` is `custom` or `append_default`. If `prompt_type` is `default`, then the `prompt` value passed will be ignored. | `"string"` |
|
|
103
|
+
| `└─ prompt_type` | ✗ | — | * `default` - Use the default recommended prompt for the art style. * `custom` - Only use the prompt passed in the API. Note: for v1, lora prompt will still be auto added to apply the art style properly. * `append_default` - Add the default recommended prompt to the end of the prompt passed in the API. | `"default"` |
|
|
104
|
+
| `└─ version` | ✗ | — | * `v1` - more detail, closer prompt adherence, and frame-by-frame previews. * `v2` - faster, more consistent, and less noisy. * `default` - use the default version for the selected art style. | `"default"` |
|
|
105
|
+
| `fps_resolution` | ✗ | ✗ | Determines whether the resulting video will have the same frame per second as the original video, or half. * `FULL` - the result video will have the same FPS as the input video * `HALF` - the result video will have half the FPS as the input video | `"HALF"` |
|
|
106
|
+
| `height` | ✗ | ✓ | `height` is deprecated and no longer influences the output video's resolution. Output resolution is determined by the **minimum** of: - The resolution of the input video - The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details. This field is retained only for backward compatibility and will be removed in a future release. | `123` |
|
|
107
|
+
| `name` | ✗ | ✗ | The name of video. This value is mainly used for your own identification of the video. | `"Video To Video video"` |
|
|
108
|
+
| `width` | ✗ | ✓ | `width` is deprecated and no longer influences the output video's resolution. Output resolution is determined by the **minimum** of: - The resolution of the input video - The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details. This field is retained only for backward compatibility and will be removed in a future release. | `123` |
|
|
109
|
+
|
|
12
110
|
#### Synchronous Client
|
|
13
111
|
|
|
14
112
|
```python
|
|
@@ -19,16 +117,13 @@ client = Client(token=getenv("API_TOKEN"))
|
|
|
19
117
|
res = client.v1.video_to_video.create(
|
|
20
118
|
assets={"video_file_path": "api-assets/id/1234.mp4", "video_source": "file"},
|
|
21
119
|
end_seconds=15.0,
|
|
22
|
-
height=960,
|
|
23
120
|
start_seconds=0.0,
|
|
24
121
|
style={
|
|
25
122
|
"art_style": "3D Render",
|
|
26
|
-
"model": "
|
|
27
|
-
"
|
|
28
|
-
"prompt_type": "append_default",
|
|
123
|
+
"model": "default",
|
|
124
|
+
"prompt_type": "default",
|
|
29
125
|
"version": "default",
|
|
30
126
|
},
|
|
31
|
-
width=512,
|
|
32
127
|
fps_resolution="HALF",
|
|
33
128
|
name="Video To Video video",
|
|
34
129
|
)
|
|
@@ -44,17 +139,26 @@ client = AsyncClient(token=getenv("API_TOKEN"))
|
|
|
44
139
|
res = await client.v1.video_to_video.create(
|
|
45
140
|
assets={"video_file_path": "api-assets/id/1234.mp4", "video_source": "file"},
|
|
46
141
|
end_seconds=15.0,
|
|
47
|
-
height=960,
|
|
48
142
|
start_seconds=0.0,
|
|
49
143
|
style={
|
|
50
144
|
"art_style": "3D Render",
|
|
51
|
-
"model": "
|
|
52
|
-
"
|
|
53
|
-
"prompt_type": "append_default",
|
|
145
|
+
"model": "default",
|
|
146
|
+
"prompt_type": "default",
|
|
54
147
|
"version": "default",
|
|
55
148
|
},
|
|
56
|
-
width=512,
|
|
57
149
|
fps_resolution="HALF",
|
|
58
150
|
name="Video To Video video",
|
|
59
151
|
)
|
|
60
152
|
```
|
|
153
|
+
|
|
154
|
+
#### Response
|
|
155
|
+
|
|
156
|
+
##### Type
|
|
157
|
+
|
|
158
|
+
[V1VideoToVideoCreateResponse](/magic_hour/types/models/v1_video_to_video_create_response.py)
|
|
159
|
+
|
|
160
|
+
##### Example
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
{"credits_charged": 450, "estimated_frame_cost": 450, "id": "cuid-example"}
|
|
164
|
+
```
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
import typing_extensions
|
|
3
3
|
|
|
4
|
-
from magic_hour.
|
|
4
|
+
from magic_hour.helpers.logger import get_sdk_logger
|
|
5
|
+
from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
|
|
6
|
+
from magic_hour.resources.v1.video_projects.client import (
|
|
7
|
+
AsyncVideoProjectsClient,
|
|
8
|
+
VideoProjectsClient,
|
|
9
|
+
)
|
|
10
|
+
from magic_hour.types import models, params
|
|
11
|
+
from make_api_request import (
|
|
5
12
|
AsyncBaseClient,
|
|
6
13
|
RequestOptions,
|
|
7
14
|
SyncBaseClient,
|
|
@@ -9,37 +16,148 @@ from magic_hour.core import (
|
|
|
9
16
|
to_encodable,
|
|
10
17
|
type_utils,
|
|
11
18
|
)
|
|
12
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
logger = get_sdk_logger(__name__)
|
|
13
22
|
|
|
14
23
|
|
|
15
24
|
class VideoToVideoClient:
|
|
16
25
|
def __init__(self, *, base_client: SyncBaseClient):
|
|
17
26
|
self._base_client = base_client
|
|
18
27
|
|
|
28
|
+
def generate(
|
|
29
|
+
self,
|
|
30
|
+
*,
|
|
31
|
+
assets: params.V1VideoToVideoGenerateBodyAssets,
|
|
32
|
+
end_seconds: float,
|
|
33
|
+
start_seconds: float,
|
|
34
|
+
style: params.V1VideoToVideoCreateBodyStyle,
|
|
35
|
+
fps_resolution: typing.Union[
|
|
36
|
+
typing.Optional[typing_extensions.Literal["FULL", "HALF"]],
|
|
37
|
+
type_utils.NotGiven,
|
|
38
|
+
] = type_utils.NOT_GIVEN,
|
|
39
|
+
height: typing.Union[
|
|
40
|
+
typing.Optional[int], type_utils.NotGiven
|
|
41
|
+
] = type_utils.NOT_GIVEN,
|
|
42
|
+
name: typing.Union[
|
|
43
|
+
typing.Optional[str], type_utils.NotGiven
|
|
44
|
+
] = type_utils.NOT_GIVEN,
|
|
45
|
+
width: typing.Union[
|
|
46
|
+
typing.Optional[int], type_utils.NotGiven
|
|
47
|
+
] = type_utils.NOT_GIVEN,
|
|
48
|
+
wait_for_completion: bool = True,
|
|
49
|
+
download_outputs: bool = True,
|
|
50
|
+
download_directory: typing.Optional[str] = None,
|
|
51
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
52
|
+
):
|
|
53
|
+
"""
|
|
54
|
+
Generate video-to-video (alias for create with additional functionality).
|
|
55
|
+
|
|
56
|
+
Create a Video To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
fps_resolution: Determines whether the resulting video will have the same frame per second as the original video, or half.
|
|
60
|
+
height: `height` is deprecated and no longer influences the output video's resolution.
|
|
61
|
+
name: The name of video. This value is mainly used for your own identification of the video.
|
|
62
|
+
width: `width` is deprecated and no longer influences the output video's resolution.
|
|
63
|
+
assets: Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
|
|
64
|
+
end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
|
|
65
|
+
start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
|
|
66
|
+
style: V1VideoToVideoCreateBodyStyle
|
|
67
|
+
wait_for_completion: Whether to wait for the video project to complete
|
|
68
|
+
download_outputs: Whether to download the outputs
|
|
69
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
70
|
+
request_options: Additional options to customize the HTTP request
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
V1VideoProjectsGetResponseWithDownloads: The response from the Video-to-Video API with the downloaded paths if `download_outputs` is True.
|
|
74
|
+
|
|
75
|
+
Examples:
|
|
76
|
+
```py
|
|
77
|
+
response = client.v1.video_to_video.generate(
|
|
78
|
+
assets={
|
|
79
|
+
"video_file_path": "path/to/video.mp4",
|
|
80
|
+
"video_source": "file",
|
|
81
|
+
},
|
|
82
|
+
end_seconds=15.0,
|
|
83
|
+
start_seconds=0.0,
|
|
84
|
+
style={
|
|
85
|
+
"art_style": "3D Render",
|
|
86
|
+
"model": "default",
|
|
87
|
+
"prompt": "cyberpunk city",
|
|
88
|
+
"prompt_type": "default",
|
|
89
|
+
"version": "default",
|
|
90
|
+
},
|
|
91
|
+
fps_resolution="HALF",
|
|
92
|
+
wait_for_completion=True,
|
|
93
|
+
download_outputs=True,
|
|
94
|
+
download_directory="outputs/",
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
100
|
+
|
|
101
|
+
# Upload video file if video_source is "file" and video_file_path is provided
|
|
102
|
+
if (
|
|
103
|
+
assets.get("video_source") == "file"
|
|
104
|
+
and "video_file_path" in assets
|
|
105
|
+
and assets["video_file_path"]
|
|
106
|
+
):
|
|
107
|
+
video_file_path = assets["video_file_path"]
|
|
108
|
+
assets["video_file_path"] = file_client.upload_file(file=video_file_path)
|
|
109
|
+
|
|
110
|
+
create_response = self.create(
|
|
111
|
+
assets=assets,
|
|
112
|
+
end_seconds=end_seconds,
|
|
113
|
+
start_seconds=start_seconds,
|
|
114
|
+
style=style,
|
|
115
|
+
fps_resolution=fps_resolution,
|
|
116
|
+
height=height,
|
|
117
|
+
name=name,
|
|
118
|
+
width=width,
|
|
119
|
+
request_options=request_options,
|
|
120
|
+
)
|
|
121
|
+
logger.info(f"Video-to-Video response: {create_response}")
|
|
122
|
+
|
|
123
|
+
video_projects_client = VideoProjectsClient(base_client=self._base_client)
|
|
124
|
+
response = video_projects_client.check_result(
|
|
125
|
+
id=create_response.id,
|
|
126
|
+
wait_for_completion=wait_for_completion,
|
|
127
|
+
download_outputs=download_outputs,
|
|
128
|
+
download_directory=download_directory,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
return response
|
|
132
|
+
|
|
19
133
|
def create(
|
|
20
134
|
self,
|
|
21
135
|
*,
|
|
22
|
-
assets: params.
|
|
136
|
+
assets: params.V1VideoToVideoCreateBodyAssets,
|
|
23
137
|
end_seconds: float,
|
|
24
|
-
height: int,
|
|
25
138
|
start_seconds: float,
|
|
26
|
-
style: params.
|
|
27
|
-
width: int,
|
|
139
|
+
style: params.V1VideoToVideoCreateBodyStyle,
|
|
28
140
|
fps_resolution: typing.Union[
|
|
29
141
|
typing.Optional[typing_extensions.Literal["FULL", "HALF"]],
|
|
30
142
|
type_utils.NotGiven,
|
|
31
143
|
] = type_utils.NOT_GIVEN,
|
|
144
|
+
height: typing.Union[
|
|
145
|
+
typing.Optional[int], type_utils.NotGiven
|
|
146
|
+
] = type_utils.NOT_GIVEN,
|
|
32
147
|
name: typing.Union[
|
|
33
148
|
typing.Optional[str], type_utils.NotGiven
|
|
34
149
|
] = type_utils.NOT_GIVEN,
|
|
150
|
+
width: typing.Union[
|
|
151
|
+
typing.Optional[int], type_utils.NotGiven
|
|
152
|
+
] = type_utils.NOT_GIVEN,
|
|
35
153
|
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
-
) -> models.
|
|
154
|
+
) -> models.V1VideoToVideoCreateResponse:
|
|
37
155
|
"""
|
|
38
156
|
Video-to-Video
|
|
39
157
|
|
|
40
158
|
Create a Video To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
41
159
|
|
|
42
|
-
Get more information about this mode at our [product page](/products/video-to-video).
|
|
160
|
+
Get more information about this mode at our [product page](https://magichour.ai/products/video-to-video).
|
|
43
161
|
|
|
44
162
|
|
|
45
163
|
POST /v1/video-to-video
|
|
@@ -48,13 +166,25 @@ class VideoToVideoClient:
|
|
|
48
166
|
fps_resolution: Determines whether the resulting video will have the same frame per second as the original video, or half.
|
|
49
167
|
* `FULL` - the result video will have the same FPS as the input video
|
|
50
168
|
* `HALF` - the result video will have half the FPS as the input video
|
|
51
|
-
|
|
169
|
+
height: `height` is deprecated and no longer influences the output video's resolution.
|
|
170
|
+
|
|
171
|
+
Output resolution is determined by the **minimum** of:
|
|
172
|
+
- The resolution of the input video
|
|
173
|
+
- The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details.
|
|
174
|
+
|
|
175
|
+
This field is retained only for backward compatibility and will be removed in a future release.
|
|
176
|
+
name: The name of video. This value is mainly used for your own identification of the video.
|
|
177
|
+
width: `width` is deprecated and no longer influences the output video's resolution.
|
|
178
|
+
|
|
179
|
+
Output resolution is determined by the **minimum** of:
|
|
180
|
+
- The resolution of the input video
|
|
181
|
+
- The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details.
|
|
182
|
+
|
|
183
|
+
This field is retained only for backward compatibility and will be removed in a future release.
|
|
52
184
|
assets: Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
|
|
53
|
-
end_seconds: The end time of the input video in seconds
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
style: PostV1VideoToVideoBodyStyle
|
|
57
|
-
width: The width of the final output video. Must be divisible by 64. The maximum width depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
|
|
185
|
+
end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
|
|
186
|
+
start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
|
|
187
|
+
style: V1VideoToVideoCreateBodyStyle
|
|
58
188
|
request_options: Additional options to customize the HTTP request
|
|
59
189
|
|
|
60
190
|
Returns:
|
|
@@ -67,18 +197,18 @@ class VideoToVideoClient:
|
|
|
67
197
|
Examples:
|
|
68
198
|
```py
|
|
69
199
|
client.v1.video_to_video.create(
|
|
70
|
-
assets={
|
|
200
|
+
assets={
|
|
201
|
+
"video_file_path": "api-assets/id/1234.mp4",
|
|
202
|
+
"video_source": "file",
|
|
203
|
+
},
|
|
71
204
|
end_seconds=15.0,
|
|
72
|
-
height=960,
|
|
73
205
|
start_seconds=0.0,
|
|
74
206
|
style={
|
|
75
207
|
"art_style": "3D Render",
|
|
76
|
-
"model": "
|
|
77
|
-
"
|
|
78
|
-
"prompt_type": "append_default",
|
|
208
|
+
"model": "default",
|
|
209
|
+
"prompt_type": "default",
|
|
79
210
|
"version": "default",
|
|
80
211
|
},
|
|
81
|
-
width=512,
|
|
82
212
|
fps_resolution="HALF",
|
|
83
213
|
name="Video To Video video",
|
|
84
214
|
)
|
|
@@ -87,22 +217,22 @@ class VideoToVideoClient:
|
|
|
87
217
|
_json = to_encodable(
|
|
88
218
|
item={
|
|
89
219
|
"fps_resolution": fps_resolution,
|
|
220
|
+
"height": height,
|
|
90
221
|
"name": name,
|
|
222
|
+
"width": width,
|
|
91
223
|
"assets": assets,
|
|
92
224
|
"end_seconds": end_seconds,
|
|
93
|
-
"height": height,
|
|
94
225
|
"start_seconds": start_seconds,
|
|
95
226
|
"style": style,
|
|
96
|
-
"width": width,
|
|
97
227
|
},
|
|
98
|
-
dump_with=params.
|
|
228
|
+
dump_with=params._SerializerV1VideoToVideoCreateBody,
|
|
99
229
|
)
|
|
100
230
|
return self._base_client.request(
|
|
101
231
|
method="POST",
|
|
102
232
|
path="/v1/video-to-video",
|
|
103
233
|
auth_names=["bearerAuth"],
|
|
104
234
|
json=_json,
|
|
105
|
-
cast_to=models.
|
|
235
|
+
cast_to=models.V1VideoToVideoCreateResponse,
|
|
106
236
|
request_options=request_options or default_request_options(),
|
|
107
237
|
)
|
|
108
238
|
|
|
@@ -111,30 +241,141 @@ class AsyncVideoToVideoClient:
|
|
|
111
241
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
112
242
|
self._base_client = base_client
|
|
113
243
|
|
|
244
|
+
async def generate(
|
|
245
|
+
self,
|
|
246
|
+
*,
|
|
247
|
+
assets: params.V1VideoToVideoGenerateBodyAssets,
|
|
248
|
+
end_seconds: float,
|
|
249
|
+
start_seconds: float,
|
|
250
|
+
style: params.V1VideoToVideoCreateBodyStyle,
|
|
251
|
+
fps_resolution: typing.Union[
|
|
252
|
+
typing.Optional[typing_extensions.Literal["FULL", "HALF"]],
|
|
253
|
+
type_utils.NotGiven,
|
|
254
|
+
] = type_utils.NOT_GIVEN,
|
|
255
|
+
height: typing.Union[
|
|
256
|
+
typing.Optional[int], type_utils.NotGiven
|
|
257
|
+
] = type_utils.NOT_GIVEN,
|
|
258
|
+
name: typing.Union[
|
|
259
|
+
typing.Optional[str], type_utils.NotGiven
|
|
260
|
+
] = type_utils.NOT_GIVEN,
|
|
261
|
+
width: typing.Union[
|
|
262
|
+
typing.Optional[int], type_utils.NotGiven
|
|
263
|
+
] = type_utils.NOT_GIVEN,
|
|
264
|
+
wait_for_completion: bool = True,
|
|
265
|
+
download_outputs: bool = True,
|
|
266
|
+
download_directory: typing.Optional[str] = None,
|
|
267
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
268
|
+
):
|
|
269
|
+
"""
|
|
270
|
+
Generate video-to-video (alias for create with additional functionality).
|
|
271
|
+
|
|
272
|
+
Create a Video To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
273
|
+
|
|
274
|
+
Args:
|
|
275
|
+
fps_resolution: Determines whether the resulting video will have the same frame per second as the original video, or half.
|
|
276
|
+
height: `height` is deprecated and no longer influences the output video's resolution.
|
|
277
|
+
name: The name of video. This value is mainly used for your own identification of the video.
|
|
278
|
+
width: `width` is deprecated and no longer influences the output video's resolution.
|
|
279
|
+
assets: Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
|
|
280
|
+
end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
|
|
281
|
+
start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
|
|
282
|
+
style: V1VideoToVideoCreateBodyStyle
|
|
283
|
+
wait_for_completion: Whether to wait for the video project to complete
|
|
284
|
+
download_outputs: Whether to download the outputs
|
|
285
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
286
|
+
request_options: Additional options to customize the HTTP request
|
|
287
|
+
|
|
288
|
+
Returns:
|
|
289
|
+
V1VideoProjectsGetResponseWithDownloads: The response from the Video-to-Video API with the downloaded paths if `download_outputs` is True.
|
|
290
|
+
|
|
291
|
+
Examples:
|
|
292
|
+
```py
|
|
293
|
+
response = await client.v1.video_to_video.generate(
|
|
294
|
+
assets={
|
|
295
|
+
"video_file_path": "path/to/video.mp4",
|
|
296
|
+
"video_source": "file",
|
|
297
|
+
},
|
|
298
|
+
end_seconds=15.0,
|
|
299
|
+
start_seconds=0.0,
|
|
300
|
+
style={
|
|
301
|
+
"art_style": "3D Render",
|
|
302
|
+
"model": "default",
|
|
303
|
+
"prompt": "cyberpunk city",
|
|
304
|
+
"prompt_type": "default",
|
|
305
|
+
"version": "default",
|
|
306
|
+
},
|
|
307
|
+
fps_resolution="HALF",
|
|
308
|
+
wait_for_completion=True,
|
|
309
|
+
download_outputs=True,
|
|
310
|
+
download_directory="outputs/",
|
|
311
|
+
)
|
|
312
|
+
```
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
316
|
+
|
|
317
|
+
# Upload video file if video_source is "file" and video_file_path is provided
|
|
318
|
+
if (
|
|
319
|
+
assets.get("video_source") == "file"
|
|
320
|
+
and "video_file_path" in assets
|
|
321
|
+
and assets["video_file_path"]
|
|
322
|
+
):
|
|
323
|
+
video_file_path = assets["video_file_path"]
|
|
324
|
+
assets["video_file_path"] = await file_client.upload_file(
|
|
325
|
+
file=video_file_path
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
create_response = await self.create(
|
|
329
|
+
assets=assets,
|
|
330
|
+
end_seconds=end_seconds,
|
|
331
|
+
start_seconds=start_seconds,
|
|
332
|
+
style=style,
|
|
333
|
+
fps_resolution=fps_resolution,
|
|
334
|
+
height=height,
|
|
335
|
+
name=name,
|
|
336
|
+
width=width,
|
|
337
|
+
request_options=request_options,
|
|
338
|
+
)
|
|
339
|
+
logger.info(f"Video-to-Video response: {create_response}")
|
|
340
|
+
|
|
341
|
+
video_projects_client = AsyncVideoProjectsClient(base_client=self._base_client)
|
|
342
|
+
response = await video_projects_client.check_result(
|
|
343
|
+
id=create_response.id,
|
|
344
|
+
wait_for_completion=wait_for_completion,
|
|
345
|
+
download_outputs=download_outputs,
|
|
346
|
+
download_directory=download_directory,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
return response
|
|
350
|
+
|
|
114
351
|
async def create(
|
|
115
352
|
self,
|
|
116
353
|
*,
|
|
117
|
-
assets: params.
|
|
354
|
+
assets: params.V1VideoToVideoCreateBodyAssets,
|
|
118
355
|
end_seconds: float,
|
|
119
|
-
height: int,
|
|
120
356
|
start_seconds: float,
|
|
121
|
-
style: params.
|
|
122
|
-
width: int,
|
|
357
|
+
style: params.V1VideoToVideoCreateBodyStyle,
|
|
123
358
|
fps_resolution: typing.Union[
|
|
124
359
|
typing.Optional[typing_extensions.Literal["FULL", "HALF"]],
|
|
125
360
|
type_utils.NotGiven,
|
|
126
361
|
] = type_utils.NOT_GIVEN,
|
|
362
|
+
height: typing.Union[
|
|
363
|
+
typing.Optional[int], type_utils.NotGiven
|
|
364
|
+
] = type_utils.NOT_GIVEN,
|
|
127
365
|
name: typing.Union[
|
|
128
366
|
typing.Optional[str], type_utils.NotGiven
|
|
129
367
|
] = type_utils.NOT_GIVEN,
|
|
368
|
+
width: typing.Union[
|
|
369
|
+
typing.Optional[int], type_utils.NotGiven
|
|
370
|
+
] = type_utils.NOT_GIVEN,
|
|
130
371
|
request_options: typing.Optional[RequestOptions] = None,
|
|
131
|
-
) -> models.
|
|
372
|
+
) -> models.V1VideoToVideoCreateResponse:
|
|
132
373
|
"""
|
|
133
374
|
Video-to-Video
|
|
134
375
|
|
|
135
376
|
Create a Video To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
136
377
|
|
|
137
|
-
Get more information about this mode at our [product page](/products/video-to-video).
|
|
378
|
+
Get more information about this mode at our [product page](https://magichour.ai/products/video-to-video).
|
|
138
379
|
|
|
139
380
|
|
|
140
381
|
POST /v1/video-to-video
|
|
@@ -143,13 +384,25 @@ class AsyncVideoToVideoClient:
|
|
|
143
384
|
fps_resolution: Determines whether the resulting video will have the same frame per second as the original video, or half.
|
|
144
385
|
* `FULL` - the result video will have the same FPS as the input video
|
|
145
386
|
* `HALF` - the result video will have half the FPS as the input video
|
|
146
|
-
|
|
387
|
+
height: `height` is deprecated and no longer influences the output video's resolution.
|
|
388
|
+
|
|
389
|
+
Output resolution is determined by the **minimum** of:
|
|
390
|
+
- The resolution of the input video
|
|
391
|
+
- The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details.
|
|
392
|
+
|
|
393
|
+
This field is retained only for backward compatibility and will be removed in a future release.
|
|
394
|
+
name: The name of video. This value is mainly used for your own identification of the video.
|
|
395
|
+
width: `width` is deprecated and no longer influences the output video's resolution.
|
|
396
|
+
|
|
397
|
+
Output resolution is determined by the **minimum** of:
|
|
398
|
+
- The resolution of the input video
|
|
399
|
+
- The maximum resolution allowed by your subscription tier. See our [pricing page](https://magichour.ai/pricing) for more details.
|
|
400
|
+
|
|
401
|
+
This field is retained only for backward compatibility and will be removed in a future release.
|
|
147
402
|
assets: Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
|
|
148
|
-
end_seconds: The end time of the input video in seconds
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
style: PostV1VideoToVideoBodyStyle
|
|
152
|
-
width: The width of the final output video. Must be divisible by 64. The maximum width depends on your subscription. Please refer to our [pricing page](https://magichour.ai/pricing) for more details
|
|
403
|
+
end_seconds: The end time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.1, and more than the start_seconds.
|
|
404
|
+
start_seconds: The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
|
|
405
|
+
style: V1VideoToVideoCreateBodyStyle
|
|
153
406
|
request_options: Additional options to customize the HTTP request
|
|
154
407
|
|
|
155
408
|
Returns:
|
|
@@ -162,18 +415,18 @@ class AsyncVideoToVideoClient:
|
|
|
162
415
|
Examples:
|
|
163
416
|
```py
|
|
164
417
|
await client.v1.video_to_video.create(
|
|
165
|
-
assets={
|
|
418
|
+
assets={
|
|
419
|
+
"video_file_path": "api-assets/id/1234.mp4",
|
|
420
|
+
"video_source": "file",
|
|
421
|
+
},
|
|
166
422
|
end_seconds=15.0,
|
|
167
|
-
height=960,
|
|
168
423
|
start_seconds=0.0,
|
|
169
424
|
style={
|
|
170
425
|
"art_style": "3D Render",
|
|
171
|
-
"model": "
|
|
172
|
-
"
|
|
173
|
-
"prompt_type": "append_default",
|
|
426
|
+
"model": "default",
|
|
427
|
+
"prompt_type": "default",
|
|
174
428
|
"version": "default",
|
|
175
429
|
},
|
|
176
|
-
width=512,
|
|
177
430
|
fps_resolution="HALF",
|
|
178
431
|
name="Video To Video video",
|
|
179
432
|
)
|
|
@@ -182,21 +435,21 @@ class AsyncVideoToVideoClient:
|
|
|
182
435
|
_json = to_encodable(
|
|
183
436
|
item={
|
|
184
437
|
"fps_resolution": fps_resolution,
|
|
438
|
+
"height": height,
|
|
185
439
|
"name": name,
|
|
440
|
+
"width": width,
|
|
186
441
|
"assets": assets,
|
|
187
442
|
"end_seconds": end_seconds,
|
|
188
|
-
"height": height,
|
|
189
443
|
"start_seconds": start_seconds,
|
|
190
444
|
"style": style,
|
|
191
|
-
"width": width,
|
|
192
445
|
},
|
|
193
|
-
dump_with=params.
|
|
446
|
+
dump_with=params._SerializerV1VideoToVideoCreateBody,
|
|
194
447
|
)
|
|
195
448
|
return await self._base_client.request(
|
|
196
449
|
method="POST",
|
|
197
450
|
path="/v1/video-to-video",
|
|
198
451
|
auth_names=["bearerAuth"],
|
|
199
452
|
json=_json,
|
|
200
|
-
cast_to=models.
|
|
453
|
+
cast_to=models.V1VideoToVideoCreateResponse,
|
|
201
454
|
request_options=request_options or default_request_options(),
|
|
202
455
|
)
|