Kling
Kling lip-sync の顔識別
Kling Lip-Sync API(POST /kling/v1/videos/identify-face)を使用して動画内の顔を検出し、高精度な lip-sync 動画生成ワークフローを実行します。
POST
/
kling
/
v1
/
videos
/
identify-face
cURL
curl https://api.cometapi.com/kling/v1/videos/identify-face \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_url": "https://your-video-host/source.mp4"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/identify-face",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"video_url": "https://your-video-host/source.mp4"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("session_id"))const response = await fetch("https://api.cometapi.com/kling/v1/videos/identify-face", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"video_url": "https://your-video-host/source.mp4"
}),
});
const result = await response.json();
console.log(result.code, result.data?.session_id);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/identify-face",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'video_url' => 'https://your-video-host/source.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/identify-face"
payload := strings.NewReader("{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/identify-face")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/identify-face")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"request_id": "<string>",
"data": {
"session_id": "<string>",
"face_data": [
{
"face_id": "<string>",
"face_image": "<string>",
"start_time": 123,
"end_time": 123
}
]
}
}下流の lip-sync ワークフローを実行する前に、このエンドポイントを使用してソース動画内の顔を識別します。
このルートが返すもの
- 現在の顔検出結果をグループ化する
session_id - 1つ以上の検出された顔を含む
face_data配列 face_id、プレビュー画像、時間範囲などの顔ごとのメタデータ
使用するタイミング
- ソースは必ず1つだけ送信します: 完了した Kling 動画には
video_id、ホストされた MP4 または MOV にはvideo_url - 画面上に複数の人物がいる動画の lip-sync リクエストを作成する前
- 自動選択に頼らず、特定の顔を選ぶ必要がある場合
- よりコストの高いタスクを開始する前に、顔の検出範囲をプレビューしたい場合
完全なパラメータリファレンスについては、Kling 公式ドキュメントを参照してください。
承認
Bearer token authentication. Use your CometAPI key.
ボディ
application/json
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/identify-face \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_url": "https://your-video-host/source.mp4"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/identify-face",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"video_url": "https://your-video-host/source.mp4"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("session_id"))const response = await fetch("https://api.cometapi.com/kling/v1/videos/identify-face", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"video_url": "https://your-video-host/source.mp4"
}),
});
const result = await response.json();
console.log(result.code, result.data?.session_id);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/identify-face",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'video_url' => 'https://your-video-host/source.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/identify-face"
payload := strings.NewReader("{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/identify-face")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/identify-face")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"video_url\": \"https://your-video-host/source.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"request_id": "<string>",
"data": {
"session_id": "<string>",
"face_data": [
{
"face_id": "<string>",
"face_image": "<string>",
"start_time": 123,
"end_time": 123
}
]
}
}