Lipsync API
Tổng Quan
Giới thiệu
Lipsync API của AusyncLab cung cấp các chức năng đồng bộ hóa chuyển động môi với âm thanh. API bao gồm hai bước chính: đăng ký video gốc và tạo video lipsync từ audio.
Tính Năng Chính
- Đăng ký và quản lý video gốc
- Tạo video lipsync với chất lượng cao
- Hỗ trợ video có hoặc không có occlusion
- Callback URL để theo dõi tiến trình xử lý
- Thumbnail tự động cho video
Quick Start
- Đăng ký và lấy API Key từ hệ thống.
- Đăng ký video gốc thông qua endpoint
/register-video
. - Chờ video được xử lý (theo dõi qua callback hoặc polling).
- Tạo lipsync video với audio mong muốn.
Xác Thực
API yêu cầu cung cấp API Key qua header X-API-Key
. API Key phải được bảo mật và không chia sẻ công khai.
Base URL
https://api.ausynclab.io/api/v1/lipsync
Playground
Thử nghiệm API tại: https://api.ausynclab.io/docs (opens in a new tab)
Chi Tiết Endpoints
1. Đăng Ký Video
URL: https://api.ausynclab.io/api/v1/lipsync/register-video
Phương thức: POST
Mô tả: Đăng ký một video gốc để sử dụng cho việc tạo lipsync.
Body:
{
"name": "Sample Video", // Tên video (tùy chọn)
"video_url": "https://example.com/video.mp4", // URL của video gốc (bắt buộc)
"callback_url": "https://your-callback-url.com" // URL được gọi khi job hoàn thành (tùy chọn)
}
CURL:
curl -X 'POST' \
'https://api.ausynclab.io/api/v1/lipsync/register-video' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"name": "Sample Video",
"video_url": "https://example.com/video.mp4",
"callback_url": "https://your-callback-url.com"
}'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 123
}
}
- 404 Not Found: Không thể đăng ký video.
- 422 Validation Error: Dữ liệu không hợp lệ.
2. Lấy Danh Sách Video Đã Đăng Ký
URL: https://api.ausynclab.io/api/v1/lipsync/register
Phương thức: GET
Mô tả: Lấy danh sách các video đã đăng ký của người dùng.
CURL:
curl -X 'GET' \
'https://api.ausynclab.io/api/v1/lipsync/register' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": [
{
"id": 123,
"name": "Sample Video",
"video_url": "https://example.com/video.mp4",
"thumbnail_url": "https://example.com/thumbnail.jpg",
"created_at": "2025-01-04T08:33:42",
"state": "COMPLETED"
},
{
"id": 124,
"name": "Another Video",
"video_url": "https://example.com/video2.mp4",
"thumbnail_url": "https://example.com/thumbnail2.jpg",
"created_at": "2025-01-04T08:30:21",
"state": "PROCESSING"
}
]
}
- 404 Not Found: Không tìm thấy danh sách video.
3. Lấy Thông Tin Chi Tiết Video Đã Đăng Ký
URL: https://api.ausynclab.io/api/v1/lipsync/register/{video_id}
Phương thức: GET
Mô tả: Lấy thông tin chi tiết của một video đã đăng ký cụ thể.
Tham số:
video_id
(bắt buộc): ID của video (kiểu integer).
CURL:
curl -X 'GET' \
'https://api.ausynclab.io/api/v1/lipsync/register/123' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 123,
"name": "Sample Video",
"video_url": "https://example.com/video.mp4",
"thumbnail_url": "https://example.com/thumbnail.jpg",
"created_at": "2025-01-04T08:33:42",
"state": "COMPLETED"
}
}
- 404 Not Found: Video không tồn tại.
4. Xóa Video Đã Đăng Ký
URL: https://api.ausynclab.io/api/v1/lipsync/register/{id}
Phương thức: DELETE
Mô tả: Xóa một video đã đăng ký cụ thể theo ID.
Tham số:
id
(bắt buộc): ID của video (kiểu integer).
CURL:
curl -X 'DELETE' \
'https://api.ausynclab.io/api/v1/lipsync/register/123' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 123,
"message": "The registered video is successfully deleted."
}
}
- 404 Not Found: Không tìm thấy video.
5. Tạo Video Lipsync
URL: https://api.ausynclab.io/api/v1/lipsync/generate-lipsync
Phương thức: POST
Mô tả: Tạo video lipsync từ video đã đăng ký và file âm thanh.
Body:
{
"name": "Lipsync Video", // Tên video lipsync (tùy chọn)
"registered_video_id": 123, // ID của video đã đăng ký (bắt buộc)
"audio_url": "https://example.com/audio.wav", // URL của file âm thanh (bắt buộc)
"callback_url": "https://your-callback-url.com" // URL được gọi khi job hoàn thành (tùy chọn)
}
CURL:
curl -X 'POST' \
'https://api.ausynclab.io/api/v1/lipsync/generate-lipsync' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"name": "Lipsync Video",
"registered_video_id": 123,
"audio_url": "https://example.com/audio.wav",
"callback_url": "https://your-callback-url.com"
}'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 456
}
}
- 404 Not Found: Không thể tạo video lipsync.
- 422 Validation Error: Dữ liệu không hợp lệ.
6. Lấy Danh Sách Video Lipsync Đã Tạo
URL: https://api.ausynclab.io/api/v1/lipsync/generate
Phương thức: GET
Mô tả: Lấy danh sách các video lipsync đã được tạo bởi người dùng.
CURL:
curl -X 'GET' \
'https://api.ausynclab.io/api/v1/lipsync/generate' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": [
{
"id": 456,
"registered_video_id": 123,
"name": "Lipsync Video",
"audio_url": "https://example.com/audio.wav",
"output_video_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-output/video456.mp4",
"thumbnail_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-thumbnails/thumb456.jpg",
"created_at": "2025-01-04T08:35:12",
"state": "COMPLETED"
},
{
"id": 457,
"registered_video_id": 124,
"name": "Another Lipsync",
"audio_url": "https://example.com/audio2.mp3",
"output_video_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-output/video457.mp4",
"thumbnail_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-thumbnails/thumb457.jpg",
"created_at": "2025-01-04T08:32:45",
"state": "PROCESSING"
}
]
}
- 404 Not Found: Không tìm thấy danh sách video lipsync.
7. Lấy Thông Tin Chi Tiết Video Lipsync
URL: https://api.ausynclab.io/api/v1/lipsync/generate/{video_id}
Phương thức: GET
Mô tả: Lấy thông tin chi tiết của một video lipsync cụ thể.
Tham số:
video_id
(bắt buộc): ID của video lipsync (kiểu integer).
CURL:
curl -X 'GET' \
'https://api.ausynclab.io/api/v1/lipsync/generate/456' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 456,
"registered_video_id": 123,
"name": "Lipsync Video",
"audio_url": "https://example.com/audio.wav",
"output_video_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-output/video456.mp4",
"thumbnail_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-thumbnails/thumb456.jpg",
"created_at": "2025-01-04T08:35:12",
"state": "COMPLETED"
}
}
- 404 Not Found: Video lipsync không tồn tại.
8. Xóa Video Lipsync
URL: https://api.ausynclab.io/api/v1/lipsync/generate/{id}
Phương thức: DELETE
Mô tả: Xóa một video lipsync cụ thể theo ID.
Tham số:
id
(bắt buộc): ID của video lipsync (kiểu integer).
CURL:
curl -X 'DELETE' \
'https://api.ausynclab.io/api/v1/lipsync/generate/456' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'
Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": 456,
"message": "The generated video is successfully deleted."
}
}
- 404 Not Found: Không tìm thấy video lipsync.
Callback Payload
Callback cho Video Đăng Ký
Khi job "Đăng ký Video" hoàn thành, API sẽ gửi thông báo đến callback_url
với payload:
Nội dung Payload:
video_id
: ID duy nhất của video đã được đăng ký.credits_used
: Số lượng tín dụng đã sử dụng để xử lý công việc này.status
: Trạng thái của công việc ("COMPLETED", "FAILED", "PROCESSING").message
: Thông báo từ hệ thống về trạng thái xử lý.
Ví dụ
{
"video_id": 123,
"credits_used": 5,
"status": "COMPLETED",
"message": "Your video registration is completed successfully"
}
Callback cho Video Lipsync
Khi job "Tạo Video Lipsync" hoàn thành, API sẽ gửi thông báo đến callback_url
với payload:
Nội dung Payload:
video_id
: ID duy nhất của video lipsync đã được tạo.video_url
: Liên kết để tải xuống video lipsync đã được hệ thống tạo.credits_used
: Số lượng tín dụng đã sử dụng để xử lý công việc này.status
: Trạng thái của công việc ("COMPLETED", "FAILED", "PROCESSING").message
: Thông báo từ hệ thống về trạng thái xử lý.
Ví dụ
{
"video_id": 456,
"video_url": "https://cdn-ausync-endpoint.azureedge.net/lipsync-output/video456.mp4",
"credits_used": 15,
"status": "COMPLETED",
"message": "Your lipsync video is generated successfully"
}
Lưu ý: Người dùng cần triển khai endpoint để nhận và xử lý payload này.
Trạng thái Video
Các trạng thái có thể của video trong hệ thống:
PROCESSING
: Video đang được xử lýCOMPLETED
: Video đã được xử lý thành côngFAILED
: Video xử lý thất bạiPENDING
: Video đang chờ xử lý
Lưu ý quan trọng
Quy trình sử dụng: Bạn cần đăng ký video gốc trước khi có thể tạo lipsync từ video đó.