Spaces:
Running
Running
Fix: add required character_orientation param to Kling Motion API call
Browse files
src/content_engine/api/routes_video.py
CHANGED
|
@@ -278,6 +278,8 @@ async def generate_kling_motion(
|
|
| 278 |
job_id = str(uuid.uuid4())[:8]
|
| 279 |
seed = seed if seed >= 0 else random.randint(0, 2**32 - 1)
|
| 280 |
|
|
|
|
|
|
|
| 281 |
image_bytes = await image.read()
|
| 282 |
video_bytes = await driving_video.read()
|
| 283 |
|
|
@@ -290,7 +292,7 @@ async def generate_kling_motion(
|
|
| 290 |
"message": "Uploading files...",
|
| 291 |
}
|
| 292 |
|
| 293 |
-
asyncio.create_task(_generate_kling_motion_video(job_id, image_bytes, video_bytes, prompt, duration))
|
| 294 |
|
| 295 |
return {"job_id": job_id, "status": "running", "estimated_time": "~60-120 seconds"}
|
| 296 |
|
|
@@ -301,6 +303,7 @@ async def _generate_kling_motion_video(
|
|
| 301 |
video_bytes: bytes,
|
| 302 |
prompt: str,
|
| 303 |
duration: int,
|
|
|
|
| 304 |
):
|
| 305 |
"""Background task: upload image + driving video, call Kling Motion Control API."""
|
| 306 |
import httpx
|
|
@@ -323,6 +326,7 @@ async def _generate_kling_motion_video(
|
|
| 323 |
"video": video_url,
|
| 324 |
"prompt": prompt,
|
| 325 |
"duration": duration,
|
|
|
|
| 326 |
"enable_sync_mode": False,
|
| 327 |
}
|
| 328 |
|
|
|
|
| 278 |
job_id = str(uuid.uuid4())[:8]
|
| 279 |
seed = seed if seed >= 0 else random.randint(0, 2**32 - 1)
|
| 280 |
|
| 281 |
+
character_orientation: str = Form("image"),
|
| 282 |
+
|
| 283 |
image_bytes = await image.read()
|
| 284 |
video_bytes = await driving_video.read()
|
| 285 |
|
|
|
|
| 292 |
"message": "Uploading files...",
|
| 293 |
}
|
| 294 |
|
| 295 |
+
asyncio.create_task(_generate_kling_motion_video(job_id, image_bytes, video_bytes, prompt, duration, character_orientation))
|
| 296 |
|
| 297 |
return {"job_id": job_id, "status": "running", "estimated_time": "~60-120 seconds"}
|
| 298 |
|
|
|
|
| 303 |
video_bytes: bytes,
|
| 304 |
prompt: str,
|
| 305 |
duration: int,
|
| 306 |
+
character_orientation: str = "image",
|
| 307 |
):
|
| 308 |
"""Background task: upload image + driving video, call Kling Motion Control API."""
|
| 309 |
import httpx
|
|
|
|
| 326 |
"video": video_url,
|
| 327 |
"prompt": prompt,
|
| 328 |
"duration": duration,
|
| 329 |
+
"character_orientation": character_orientation,
|
| 330 |
"enable_sync_mode": False,
|
| 331 |
}
|
| 332 |
|
src/content_engine/api/ui.html
CHANGED
|
@@ -1138,6 +1138,12 @@ select { cursor: pointer; }
|
|
| 1138 |
</div>
|
| 1139 |
<input type="file" id="kling-motion-video-input" accept="video/*" style="display:none" onchange="handleKlingMotionVideo(this)">
|
| 1140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1141 |
<label style="margin-top:10px">Duration</label>
|
| 1142 |
<select id="kling-motion-duration">
|
| 1143 |
<option value="5" selected>5s (~$0.56)</option>
|
|
@@ -2538,6 +2544,7 @@ async function doGenerate() {
|
|
| 2538 |
formData.append('driving_video', klingMotionVideoFile);
|
| 2539 |
formData.append('prompt', document.getElementById('gen-positive').value || 'smooth motion, high quality video');
|
| 2540 |
formData.append('duration', document.getElementById('kling-motion-duration').value || '5');
|
|
|
|
| 2541 |
formData.append('seed', document.getElementById('gen-seed').value || '-1');
|
| 2542 |
const res = await fetch(API + '/api/video/generate/kling-motion', { method: 'POST', body: formData });
|
| 2543 |
const data = await res.json();
|
|
|
|
| 1138 |
</div>
|
| 1139 |
<input type="file" id="kling-motion-video-input" accept="video/*" style="display:none" onchange="handleKlingMotionVideo(this)">
|
| 1140 |
|
| 1141 |
+
<label style="margin-top:10px">Orientation</label>
|
| 1142 |
+
<select id="kling-motion-orientation">
|
| 1143 |
+
<option value="image" selected>Match image framing</option>
|
| 1144 |
+
<option value="video">Match video framing (up to 30s)</option>
|
| 1145 |
+
</select>
|
| 1146 |
+
|
| 1147 |
<label style="margin-top:10px">Duration</label>
|
| 1148 |
<select id="kling-motion-duration">
|
| 1149 |
<option value="5" selected>5s (~$0.56)</option>
|
|
|
|
| 2544 |
formData.append('driving_video', klingMotionVideoFile);
|
| 2545 |
formData.append('prompt', document.getElementById('gen-positive').value || 'smooth motion, high quality video');
|
| 2546 |
formData.append('duration', document.getElementById('kling-motion-duration').value || '5');
|
| 2547 |
+
formData.append('character_orientation', document.getElementById('kling-motion-orientation').value || 'image');
|
| 2548 |
formData.append('seed', document.getElementById('gen-seed').value || '-1');
|
| 2549 |
const res = await fetch(API + '/api/video/generate/kling-motion', { method: 'POST', body: formData });
|
| 2550 |
const data = await res.json();
|