Kling
为 Kling 唇形同步识别人脸
使用 Kling 唇形同步 API(POST /kling/v1/videos/identify-face)检测视频中的人脸,并驱动精确的唇形同步视频生成工作流。
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
}
]
}
}在运行下游唇形同步工作流之前,使用此端点识别源视频中的人脸。
此路由返回什么
- 一个用于归组当前人脸检测结果的
session_id - 一个包含一个或多个人脸的
face_data数组 - 每张人脸的元数据,例如
face_id、预览图像和时间范围
何时使用它
- 精确传入一个来源:已完成的 Kling 视频使用
video_id,托管的 MP4 或 MOV 使用video_url - 在你为屏幕中有多人的视频构建唇形同步请求之前
- 当你需要选择特定人脸,而不是依赖自动选择时
- 当你想在启动成本更高的任务之前预览人脸覆盖范围时
有关完整的参数参考,请参阅官方 Kling 文档。
授权
Bearer token authentication. Use your CometAPI key.
请求体
application/json
最后修改于 2026年6月25日
⌘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
}
]
}
}