视频超清
描述
本接口用于视频超清请求,具体效果请看以下文档详情。
版本
2.0
图片要求
视频格式
格式:h263、h264、h265、AV1、MPEG4、VP8、VP9
视频大小
最小:144*144 以内 pvg不支持 最大:硬件编解码最大支持长边4096 + 宽、高必须是偶数
调用 URL
正式环境:https://openapi.meitu.com
任务提交接口:https://openapi.meitu.com/api/v1/sdk/sync/push
任务名称(task):/v1/video_super_resolution/488146
任务类型(task_type):formula调用方法
POST
Content-Type: application/json
权限
请求参数
| 是否必选 | 参数名 | 类型 | 参数说明 |
|---|---|---|---|
| 必选 | task | String | 任务路径,例如:/v1/video_super_resolution/488146 |
| 必选 | task_type | String | 任务类型,固定值:formula |
| 必选 | init_images | Object[] | 输入的媒体文件参数 |
| 必选 | params | String | 推理参数(JSON 字符串格式) |
| 可选 | sync_timeout | Int | 默认 30,同步超时时间 |
init_images 多媒体文件参数,结构说明如下
init_images 为数组类型,每个元素表示一个媒体资源(如视频、水印图片等)。
| 是否必选 | 参数名 | 类型 | 参数说明 |
|---|---|---|---|
| 必选 | url | String | 媒体文件访问地址 |
| 必选 | profile | Object | 多媒体参数配置 |
profile 参数说明
| 是否必选 | 参数名 | 类型 | 参数说明 |
|---|---|---|---|
| 必选 | media_profiles | object | 媒体文件的相关属性信息描述 |
| 必选 | version | String | 固定 v1 |
media_profiles 中参数说明
| 是否必选 | 参数名 | 类型 | 参数说明 |
|---|---|---|---|
| 必选 | media_data_type | String | url 表示 URL;其他对应类型表示 base64 |
params 推理参数说明
params 为 JSON 字符串,解析后的结构如下:
{
"rsp_media_type": "url",
"parameter": {
"media_data_type": "url",
"open_degree": 0,
"assign_degree": 80,
"sharp_degree": 5,
"more_face": 1,
"sr_rate": 1
}
}params 字段说明
| 是否必选 | 字段 | 类型 | 说明 |
|---|---|---|---|
| 可选 | rsp_media_type | String | 默认 url;jpg 表示 base64 |
| 必选 | parameter | Object | 算法核心参数对象 |
parameter 参数说明
| 是否必填 | 参数名 | 类型 | 参数说明 |
|---|---|---|---|
| 否 | media_data_type | String | 图片数据类型: • jpg:表示 media_data 为 base64 编码图片(默认)• url:表示 media_data 为图片 URL 地址 |
| 否 | open_degree | Int | 开放程度: • 1:支持开放 • 0:不支持(默认) |
| 否 | assign_degree | Int | 人像修复程度,范围 [0, 100],默认 80 |
| 否 | skip_frames | Int[] | 跳帧设置: • [start, end]:分别表示首尾跳过帧数• [0,0]:分片但不跳过• None:不分片(默认) |
| 否 | sharp_degree | Int | 锐化程度,范围 [0, 10],默认 5 |
| 否 | more_face | Int | 是否增强更多人脸: • 1:开启(修复小人脸/侧脸) • 0:关闭(默认) |
| 否 | save_rate | Int | 输出视频码率相对输入的最大倍数: • 0:不限制(默认) |
| 否 | sr_rate | Float | 分辨率放大倍数,默认 1 |
输入值示例
{
"task": "/v1/video_super_resolution/488146",
"task_type": "formula",
"init_images": [
{
"url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTczOTUxNjQwMA==/5164853f-02af-4ce9-6c1d-fc5a68c247cd.mp4",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}
],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"media_data_type\":\"url\",\"open_degree\":0,\"assign_degree\":80,\"sharp_degree\":5,\"more_face\":1,\"sr_rate\":1}}",
"sync_timeout": 30
}返回值说明
注意,生成的结果,会定期清理,请及时下载保存| 字段 | 类型 | 参数说明 |
|---|---|---|
| request_id | String | 请求 ID |
| trace_id | String | 链路追踪 ID |
| code | Number | HTTP 层状态码,0 表示成功 |
| error_code | Number | 业务错误码,0 表示成功,详见 API 错误码 |
| message | String | 返回信息,成功时为 success |
| tips | any | 补充提示,可为 null |
| data | Object | 返回的业务数据 |
data 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| status | Number | -1 未找到任务;0 创建成功;1 执行中;2 失败;9 超时,需使用查询接口查询;10 成功 |
| result | Object | 任务处理结果 |
| progress | Number | 任务进度,取值范围 0~1,1 表示完成 |
| predict_elapsed | Number | 预测处理耗时,单位:毫秒 |
| create_time | Number | 任务创建时间戳,单位:毫秒 |
| task_id | String | 任务 ID |
| custom_task_id | String | 自定义任务 ID |
| trace_id | String | 跟踪 ID |
| client_info | String | 客户端信息 |
| init_images | Array | 初始输入媒体信息 |
result 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| id | String | 任务唯一标识 |
| urls | String[] | 输出媒体 URL 列表 |
| images | String[] | 输出媒体(兼容字段) |
| msg | String | 返回信息 |
| msg_id | String | 消息 ID |
| parameters | Object | 输出参数信息 |
| data | Object | 详细处理结果 |
| media_info_list | Array | 媒体信息列表 |
| mtlab_res | Object | 底层服务返回信息 |
result.parameters 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| rsp_media_type | String | 返回媒体类型,如 url |
| version | String | 算法版本信息 |
result.data 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| duration | Object | 各阶段耗时 |
| error_code | Number | 错误码 |
| error_msg | String | 错误信息 |
| extra | Object | 扩展信息 |
| media_info_list | Array | 媒体信息列表 |
| msg_id | String | 消息 ID |
| parameter | Object | 参数信息(同 parameters) |
duration 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| alg_process_time | Number | 算法处理耗时(毫秒) |
| created_timestamp | Number | 创建时间(秒级时间戳) |
| pull_timestamp | Number | 拉取时间 |
| repost_time | Number | 重试时间 |
| upload_time | Number | 上传耗时 |
| waiting_time | Number | 排队耗时 |
extra 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| algo_msg | Object | 算法内部信息 |
| sale_path | String | 接口路径 |
| trans_meta | Object | 转码信息 |
algo_msg 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| alg_time | Float | 算法执行时间(秒) |
trans_meta 字段说明 req_meta(输入信息)
| 字段 | 类型 | 参数说明 |
|---|---|---|
| duration | Float | 输入媒体时长 |
| media_type | String | 媒体类型 |
rsp_meta(输出信息)
| 字段 | 类型 | 参数说明 |
|---|---|---|
| data_rate | Float | 码率 |
| duration | Number | 时长 |
| frame_num | Number | 帧数 |
| frame_rate | Number | 帧率 |
| height | Number | 高度 |
| width | Number | 宽度 |
| resolution | String | 分辨率(如 480P) |
| size | Number | 文件大小(字节) |
| media_type | String | 媒体类型 |
media_info_list 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| media_data | String | 媒体 URL |
| media_extra | Object | 扩展信息 |
| media_profiles | Object | 媒体属性 |
media_profiles 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| media_data_fps | Number | 帧率 |
| media_data_height | Number | 高度 |
| media_data_width | Number | 宽度 |
| media_data_size | Number | 文件大小 |
| media_data_type | String | 媒体类型(如 url) |
mtlab_res 字段说明
| 字段 | 类型 | 参数说明 |
|---|---|---|
| ErrorCode | Number | 错误码 |
| ErrorMsg | String | 错误信息 |
| error_code | Number | 错误码(兼容字段) |
| error_msg | String | 错误信息(兼容字段) |
| media_info_list | Array | 媒体信息 |
| msg_id | String | 消息 ID |
| parameter | Object | 参数信息 |
返回值示例
请求成功返回示例
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 10,
"result": {
"id": "t_mt1a3i5n7b4bd06996-xxxx-4c99-a31c-ed25400c652a",
"urls": [
"https://obs-large.mtlab.meitu.com/mtopen/4e200dc6bf574fee899cf9e0dabe27e6/356436f0-4825-4008-6aea-d691258e6ff5.mp4"
],
"parameters": {
"rsp_media_type": "url",
"version": "HDVideo version: 2.9.1 - 更新parsing trt加速"
},
"data": {
"duration": {
"alg_process_time": 981,
"created_timestamp": 1773727956,
"pull_timestamp": 1773727956,
"repost_time": 0,
"upload_time": 52,
"waiting_time": 352
},
"error_code": 0,
"error_msg": "success",
"extra": {
"algo_msg": {
"alg_time": 0.8139691352844238
},
"sale_path": "/v2/hdvideo_async",
"trans_meta": {
"req_meta": [
{
"duration": 2222.222,
"media_type": "video"
}
],
"rsp_meta": [
{
"data_rate": 3448.156568771866,
"duration": 2222,
"frame_num": 40,
"frame_rate": 18,
"height": 512,
"media_type": "video",
"resolution": "480P",
"size": 995569,
"width": 512
}
]
}
},
"media_info_list": [
{
"media_data": "https://obs-large.mtlab.meitu.com/mtopen/4e200dc6bf574fee899cf9e0dabe27e6/356436f0-4825-4008-6aea-d691258e6ff5.mp4",
"media_extra": null,
"media_profiles": {
"media_data_fps": 18,
"media_data_height": 512,
"media_data_size": 995569,
"media_data_type": "url",
"media_data_width": 512
}
}
],
"msg_id": "38b4d91c-xxxx-4ead-6efd-r0099ef38e03",
"parameter": {
"rsp_media_type": "url",
"version": "HDVideo version: 2.9.1 - 更新parsing trt加速"
}
},
"msg": "success",
"msg_id": "38b4d91c-xxxx-4ead-6efd-r0099ef38e03",
"images": [
"https://obs-large.mtlab.meitu.com/mtopen/4e200dc6bf574fee899cf9e0dabe27e6/356436f0-4825-4008-6aea-d691258e6ff5.mp4"
],
"mtlab_res": {
"ErrorCode": 0,
"ErrorMsg": "",
"error_code": 0,
"error_msg": "",
"media_info_list": null,
"msg_id": "38b4d91c-xxxx-4ead-6efd-r0099ef38e03",
"parameter": null
},
"media_info_list": [
{
"media_data": "https://obs-large.mtlab.meitu.com/mtopen/4e200dc6bf574fee899cf9e0dabe27e6/356436f0-4825-4008-6aea-d691258e6ff5.mp4",
"media_extra": null,
"media_profiles": {
"media_data_fps": 18,
"media_data_height": 512,
"media_data_size": 995569,
"media_data_type": "url",
"media_data_width": 512
}
}
]
},
"progress": 1,
"predict_elapsed": 10000,
"create_time": 1773727956523,
"task_id": "t_mt1a3i5n7b4bd06996-xxxx-4c99-a31c-ed25400c652a",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}需要查询返回示例
使用 查询接口 接口查询
Response Status:200
content-type 为 application/json; charset=utf-8
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 9,
"result": {
"id": "t_mt1a3i5n7ba8ab7851-xxxx-4218-95a1-fcc0216ac625"
},
"progress": 0,
"predict_elapsed": 10000,
"create_time": 1773733189030,
"task_id": "t_mt1a3i5n7ba8ab7851-xxxx-4218-95a1-fcc0216ac625",
"custom_task_id": "",
"trace_id": "65280ef2-xxxx-4e3f-99a7-3db499379104",
"client_info": "",
"init_images": null
}
}请求失败返回示例
Response Status:400
content-type 为 application/json; charset=utf-8
{
"request_id": "",
"trace_id": "",
"code": 20001,
"error_code": 20001,
"message": "PROCESS_ERROR",
"tips": null,
"data": {
"status": 2,
"result": {
"error_code": 20001,
"message": "PROCESS_ERROR"
},
"progress": 0,
"predict_elapsed": 0,
"create_time": 0,
"task_id": "",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}通用的错误代码与信息
详见 API 错误码
SDK 调用示例
Python
使用 from sign_sdk import sign:
import json
import requests
from sign_sdk import sign
def api_call_example():
key = "your_api_key"
secret = "your_api_secret"
url = "https://openapi.meitu.com/api/v1/sdk/sync/push"
method = "POST"
headers = {
"Content-Type": "application/json",
sign.HeaderHost: "openapi.meitu.com",
}
inner_params = {
"rsp_media_type": "url",
"parameter": {"media_data_type": "url", "open_degree": 0, "assign_degree": 80, "sharp_degree": 5, "more_face": 1, "sr_rate": 1},
}
payload = {
"task": "/v1/video_super_resolution/488146",
"task_type": "formula",
"init_images": [
{
"url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTczOTUxNjQwMA==/5164853f-02af-4ce9-6c1d-fc5a68c247cd.mp4",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1",
},
}
],
"params": json.dumps(inner_params, ensure_ascii=False),
"sync_timeout": 30,
}
body = json.dumps(payload, ensure_ascii=False)
signer = sign.Signer(key, secret)
signed_request = signer.sign(url, method, headers, body)
response = requests.Session().send(signed_request)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
if __name__ == "__main__":
api_call_example()Go
使用 github.com/mtlab/api/signer:
package main
import (
"fmt"
"io"
"net/http"
"github.com/mtlab/api/signer"
)
func main() {
key := "your_api_key"
secret := "your_api_secret"
signObj := signer.NewSigner(key, secret)
url := "https://openapi.meitu.com/api/v1/sdk/sync/push"
method := http.MethodPost
headers := make(http.Header)
headers.Set(signer.HeaderHost, "openapi.meitu.com")
headers.Set("Content-Type", "application/json")
body := `{
"task": "/v1/video_super_resolution/488146",
"task_type": "formula",
"init_images": [{
"url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTczOTUxNjQwMA==/5164853f-02af-4ce9-6c1d-fc5a68c247cd.mp4",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"media_data_type\":\"url\",\"open_degree\":0,\"assign_degree\":80,\"sharp_degree\":5,\"more_face\":1,\"sr_rate\":1}}",
"sync_timeout": 30
}`
req, err := signObj.Sign(url, method, headers, body)
if err != nil {
fmt.Println("Failed to sign request:", err)
return
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Failed to send request:", err)
return
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Read response failed:", err)
return
}
fmt.Println("Response:", resp.StatusCode, string(responseBody))
}PHP
使用 signer.php:
<?php
require 'signer.php';
$key = 'your_api_key';
$secret = 'your_api_secret';
$signer = new Signer($key, $secret);
$url = 'https://openapi.meitu.com/api/v1/sdk/sync/push';
$method = 'POST';
$headers = ['Content-Type' => 'application/json'];
$innerParams = json_encode([
'rsp_media_type' => 'url',
'parameter' => ['media_data_type' => 'url', 'open_degree' => 0, 'assign_degree' => 80, 'sharp_degree' => 5, 'more_face' => 1, 'sr_rate' => 1],
]);
$body = json_encode([
'task' => '/v1/video_super_resolution/488146',
'task_type' => 'formula',
'init_images' => [
[
'url' => 'https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTczOTUxNjQwMA==/5164853f-02af-4ce9-6c1d-fc5a68c247cd.mp4',
'profile' => [
'media_profiles' => ['media_data_type' => 'url'],
'version' => 'v1',
],
],
],
'params' => $innerParams,
'sync_timeout' => 30,
]);
$curl = $signer->sign($url, $method, $headers, $body);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status === 0) {
echo 'Error: ' . curl_error($curl);
} else {
echo "Status: {$status}\n";
echo "Response: {$response}\n";
}
curl_close($curl);
?>Java
使用项目提供的 Signer,并把实际 body 传入签名:
package com.meitu.openai.common;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws Exception {
Signer signer = new Signer("your_api_key", "your_api_secret");
String url = "https://openapi.meitu.com/api/v1/sdk/sync/push";
String method = "POST";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put(Signer.HeaderHost, "openapi.meitu.com");
String body = "{\n" +
" \"task\": \"/v1/video_super_resolution/488146\",\n" +
" \"task_type\": \"formula\",\n" +
" \"init_images\": [{\n" +
" \"url\": \"https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTczOTUxNjQwMA==/5164853f-02af-4ce9-6c1d-fc5a68c247cd.mp4\",\n" +
" \"profile\": {\n" +
" \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
" \"version\": \"v1\"\n" +
" }\n" +
" }],\n" +
" \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"media_data_type\\\":\\\"url\\\",\\\"open_degree\\\":0,\\\"assign_degree\\\":80,\\\"sharp_degree\\\":5,\\\"more_face\\\":1,\\\"sr_rate\\\":1}}\",\n" +
" \"sync_timeout\": 30\n" +
"}";
Map<String, String> signedHeaders = signer.sign(url, method, headers, body);
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod(method);
for (Map.Entry<String, String> entry : signedHeaders.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
connection.setDoOutput(true);
connection.getOutputStream().write(body.getBytes(StandardCharsets.UTF_8));
int status = connection.getResponseCode();
InputStream stream = status >= 400
? connection.getErrorStream()
: connection.getInputStream();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
System.out.println("Response: " + status + " " + response);
}
}
}