Video Super Resolution

Description

This API provides video super-resolution processing. See the details below for supported options and response structures.

Version

2.0

Media Requirements

Video Formats

Supported formats: h263, h264, h265, AV1, MPEG4, VP8, and VP9.

Video Dimensions

Minimum: pvg does not support dimensions smaller than 144*144. Maximum: hardware codecs support a maximum long edge of 4096 pixels, and both the width and height must be even numbers.

API URL

Production environment: https://openapi.meitu.com
Task submission endpoint: https://openapi.meitu.com/api/v1/sdk/sync/push
Task name (`task`): /v1/video_super_resolution/488146
Task type (`task_type`): formula

Method

POST

Content-Type: application/json

Authentication

Open Platform API Signature

Request Parameters

RequiredParameterTypeDescription
YestaskStringTask path, for example: /v1/video_super_resolution/488146
Yestask_typeStringTask type. Fixed value: formula
Yesinit_imagesObject[]Input media file parameters
YesparamsStringInference parameters (JSON string)
Nosync_timeoutIntSynchronous timeout in seconds. Default: 30

init_images media file parameters are described below.

init_images is an array. Each element represents a media resource, such as a video or watermark image.

RequiredParameterTypeDescription
YesurlStringMedia file URL
YesprofileObjectMedia configuration

profile parameters

RequiredParameterTypeDescription
Yesmedia_profilesobjectMedia file attributes
YesversionStringFixed value: v1

Parameters in media_profiles

RequiredParameterTypeDescription
Yesmedia_data_typeStringurl indicates a URL; other corresponding types indicate base64 data

params inference parameters

params is a JSON string. Its decoded structure is as follows:

{
  "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 fields

RequiredFieldTypeDescription
Norsp_media_typeStringDefault: url; jpg indicates base64 data
YesparameterObjectCore algorithm parameter object

parameter parameters

RequiredParameterTypeDescription
Nomedia_data_typeStringImage data type:
jpg: media_data is a base64-encoded image (default)
url: media_data is an image URL
Noopen_degreeIntOpenness setting:
1: enabled
0: disabled (default)
Noassign_degreeIntPortrait restoration intensity. Range: [0, 100]; default: 80
Noskip_framesInt[]Frame skipping configuration:
[start, end]: number of frames to skip at the beginning and end, respectively
[0,0]: split into segments without skipping frames
None: do not split into segments (default)
Nosharp_degreeIntSharpening intensity. Range: [0, 10]; default: 5
Nomore_faceIntWhether to enhance more faces:
1: enabled (restores small or profile faces)
0: disabled (default)
Nosave_rateIntMaximum output-to-input video bitrate ratio:
0: unlimited (default)
Nosr_rateFloatResolution upscaling factor. Default: 1

Request Example

{
  "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
}

Response Fields

Generated results are periodically deleted. Download and save them promptly.
FieldTypeDescription
request_idStringRequest ID
trace_idStringTrace ID
codeNumberHTTP-layer status code; 0 indicates success
error_codeNumberBusiness error code; 0 indicates success. See API Error Codes
messageStringResponse message; success on success
tipsanyAdditional information; may be null
dataObjectBusiness response data

data fields

FieldTypeDescription
statusNumber-1: task not found; 0: created; 1: processing; 2: failed; 9: timed out—use the Query API; 10: succeeded
resultObjectTask processing result
progressNumberTask progress in the range 0–1; 1 indicates completion
predict_elapsedNumberEstimated processing time in milliseconds
create_timeNumberTask creation timestamp in milliseconds
task_idStringTask ID
custom_task_idStringCustom task ID
trace_idStringTrace ID
client_infoStringClient information
init_imagesArrayInitial input media information

result fields

FieldTypeDescription
idStringUnique task identifier
urlsString[]Output media URL list
imagesString[]Output media (compatibility field)
msgStringResponse message
msg_idStringMessage ID
parametersObjectOutput parameter information
dataObjectDetailed processing result
media_info_listArrayMedia information list
mtlab_resObjectUnderlying service response

result.parameters fields

FieldTypeDescription
rsp_media_typeStringResponse media type, such as url
versionStringAlgorithm version information

result.data fields

FieldTypeDescription
durationObjectProcessing time for each stage
error_codeNumberError code
error_msgStringError message
extraObjectAdditional information
media_info_listArrayMedia information list
msg_idStringMessage ID
parameterObjectParameter information (same as parameters)

duration fields

FieldTypeDescription
alg_process_timeNumberAlgorithm processing time in milliseconds
created_timestampNumberCreation time as a Unix timestamp in seconds
pull_timestampNumberPull time
repost_timeNumberRetry time
upload_timeNumberUpload time
waiting_timeNumberQueueing time

extra fields

FieldTypeDescription
algo_msgObjectInternal algorithm information
sale_pathStringAPI path
trans_metaObjectTranscoding information

algo_msg fields

FieldTypeDescription
alg_timeFloatAlgorithm execution time in seconds

trans_meta fields

req_meta (input information)

FieldTypeDescription
durationFloatInput media duration
media_typeStringMedia type

rsp_meta (output information)

FieldTypeDescription
data_rateFloatBitrate
durationNumberDuration
frame_numNumberFrame count
frame_rateNumberFrame rate
heightNumberHeight
widthNumberWidth
resolutionStringResolution, such as 480P
sizeNumberFile size in bytes
media_typeStringMedia type

media_info_list fields

FieldTypeDescription
media_dataStringMedia URL
media_extraObjectAdditional information
media_profilesObjectMedia attributes

media_profiles fields

FieldTypeDescription
media_data_fpsNumberFrame rate
media_data_heightNumberHeight
media_data_widthNumberWidth
media_data_sizeNumberFile size
media_data_typeStringMedia type, such as url

mtlab_res fields

FieldTypeDescription
ErrorCodeNumberError code
ErrorMsgStringError message
error_codeNumberError code (compatibility field)
error_msgStringError message (compatibility field)
media_info_listArrayMedia information
msg_idStringMessage ID
parameterObjectParameter information

Response Examples

Successful Response Example

{
  "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
  }
}

Query-Required Response Example

Use the Query API to retrieve the result.

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
  }
}

Failed Response Example

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
  }
}

General Error Codes

See API Error Codes.

SDK Examples

Python

Use 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

Use 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

Use 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

Use the project-provided Signer, passing the actual request body to the signing method:

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);
        }
    }
}