Video Subtitle Removal

Description

This API processes video subtitle removal requests in the cloud.

Version

1.0

Media Requirements

The input media must be an MP4 video.

API URL

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

Method

POST

Content-Type: application/json

Authentication

Open Platform API Signature

Request Parameters

RequiredParameterTypeDescription
YesparamsstringAlgorithm parameters (JSON string)
Yesinit_imagesobject[]List of video files
YestaskstringFixed value: /v1/videosubtitle_remove/485023
Yestask_typestringFixed value: formula
Nosync_timeoutintDefault: 30. If synchronous processing times out, status=9 is returned and the query API can be used to retrieve the result.

The init_images multimedia file parameters are structured as follows:

RequiredParameterTypeDescription
YesurlstringVideo URL or base64-encoded data
YesprofileobjectMedia attribute information

The profile attribute information is structured as follows:

RequiredParameterTypeDescription
Yesmedia_profilesobjectMedia attributes
YesversionstringFixed value: v1

The media_profiles media attributes are structured as follows:

RequiredParameterTypeDescription
Yesmedia_data_typestringurl indicates a URL; the corresponding media type indicates base64-encoded data.

The params inference parameters are provided as a JSON string with the following structure:

RequiredFieldTypeDescription
Norsp_media_typestringDefault: url, which returns the result as a URL.
YesparameterobjectCore algorithm parameter object

Details of the parameter algorithm parameters:

RequiredFieldTypeDescription
NoversionstringAlgorithm version. Supported values include 1.0.0 and 2.0.0; default: 1.0.0.
NouserboxesstringUser-defined bounding-box coordinates. Starting at the upper-left corner, provide normalized coordinates for four points clockwise through the lower-left corner. No default box is specified.

Request Example

{
  "task": "/v1/videosubtitle_remove/485023",
  "task_type": "formula",
  "init_images": [
    {
      "url": "https://xxx.mp4",
      "profile": {
        "media_profiles": {
          "media_data_type": "url"
        },
        "version": "v1"
      }
    }
  ],
  "params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"userboxes\":\"[[[0, 0.5], [1, 0.5], [1, 0.8], [0, 0.8]]]\"}}",
  "sync_timeout": 30
}

Response Fields

Generated results are periodically deleted. Download and save them promptly.
FieldTypeDescription
request_idstringRequest identifier
trace_idstringTrace identifier
codeintBusiness status code; 0 indicates that the request was accepted successfully.
error_codeintError code; 0 indicates success.
messagestringBusiness message
tipsanyAdditional information; may be null.
dataobjectTask status and algorithm result

Fields in data:

FieldTypeDescription
statusintStatus code: -1, task not found; 0, created successfully; 1, processing; 2, failed; 9, timed out—use the Query API; 10, succeeded.
resultobjectAlgorithm result
progressnumberTask progress
predict_elapsedintEstimated processing time in milliseconds
create_timeint64Creation timestamp in milliseconds
task_idstringTask ID
custom_task_idstringClient-defined task ID
trace_idstringTrace identifier within data
client_infostringClient information
init_imagesobject[]/nullEcho of the input media

Fields in result:

FieldTypeDescription
idstringResult task ID
urlsarrayList of output video URLs
imagesarrayList of output image or video URLs
parametersobjectEcho of request parameters
dataobjectInternal result data, including timing and media information
msgstringResponse message
msg_idstringMessage ID
mtlab_resobjectMTLab-compatible result fields, including error information
media_info_listarrayList of media information

Fields in result.parameters:

FieldTypeDescription
exist_textboolWhether subtitle text is present
rsp_media_typestringResponse media type, such as url
versionstringAlgorithm version information, such as VideoSubtitleRemove version: 2.0.3

Fields in result.data:

FieldTypeDescription
durationobjectTiming information by category
error_codeintError code
error_msgstringError message
extraobjectAdditional data
media_info_listarrayList of media data
msg_idstringMessage ID
parameterobjectParameters; identical to parameters

Fields in result.data.duration:

FieldTypeDescription
alg_process_timeintAlgorithm processing time
created_timestampint64Creation timestamp
pull_timestampint64Pull timestamp
repost_timeintForwarding time
upload_timeintUpload time
waiting_timeintWaiting time

Fields in the result.data.extra.trans_meta.rsp_meta array:

FieldTypeDescription
data_ratefloatData bitrate
durationintDuration
frame_numintNumber of frames
frame_ratefloatFrame rate
heightintHeight
media_typestringMedia type
sizeintFile size
widthintWidth

Fields in each media_info_list array element:

FieldTypeDescription
media_datastringMedia URL
media_extraobject/nullAdditional information
media_profilesobjectMedia attributes

Fields in media_profiles:

FieldTypeDescription
media_data_fpsfloatFrame rate
media_data_heightintHeight
media_data_sizeintFile size
media_data_typestringType, such as url
media_data_widthintWidth

Fields in mtlab_res:

FieldTypeDescription
ErrorCodeintError code
ErrorMsgstringError message
error_codeintError code
error_msgstringError message
media_info_listarray/nullMedia information
msg_idstringMessage ID
parameterobject/nullParameters

Response Examples

Successful Response Example

{
  "request_id": "request_id",
  "trace_id": "trace_id",
  "code": 0,
  "error_code": 0,
  "message": "success",
  "tips": null,
  "data": {
    "status": 10,
    "result": {
      "id": "task_id",
      "urls": [
        "https://obs-large.mtlab.meitu.com/mtopen/30f1b44ea57c4d94bbdfda14005b7332/e034c450-6ca4-4b2e-409d-b594a35cce50/e034c450-6ca4-4b2e-409d-b594a35cce50.mp4"
      ],
      "images": [
        "https://obs-large.mtlab.meitu.com/mtopen/30f1b44ea57c4d94bbdfda14005b7332/e034c450-6ca4-4b2e-409d-b594a35cce50/e034c450-6ca4-4b2e-409d-b594a35cce50.mp4"
      ],
      "parameters": {
        "exist_text": true,
        "rsp_media_type": "url",
        "version": "VideoSubtitleRemove version: 2.0.3"
      },
      "data": {
        "duration": {
          "alg_process_time": 158283,
          "created_timestamp": 1765098852,
          "pull_timestamp": 1765098852,
          "repost_time": 0,
          "upload_time": 1135,
          "waiting_time": 153
        },
        "error_code": 0,
        "error_msg": "success",
        "extra": {
          "trans_meta": {
            "rsp_meta": [
              {
                "data_rate": 51369.922,
                "duration": 0,
                "frame_num": 1537,
                "frame_rate": 29.92023277282715,
                "height": 720,
                "media_type": "video",
                "size": 33731714,
                "width": 960
              }
            ]
          }
        },
        "media_info_list": [
          {
            "media_data": "https://obs-large.mtlab.meitu.com/mtopen/30f1b44ea57c4d94bbdfda14005b7332/e034c450-6ca4-4b2e-409d-b594a35cce50/e034c450-6ca4-4b2e-409d-b594a35cce50.mp4",
            "media_extra": null,
            "media_profiles": {
              "media_data_fps": 29.92023277282715,
              "media_data_height": 720,
              "media_data_size": 33731714,
              "media_data_type": "url",
              "media_data_width": 960
            }
          }
        ],
        "msg_id": "msg_id",
        "parameter": {
          "exist_text": true,
          "rsp_media_type": "url",
          "version": "VideoSubtitleRemove version: 2.0.3"
        }
      },
      "msg": "success",
      "msg_id": "msg_id",
      "mtlab_res": {
        "ErrorCode": 0,
        "ErrorMsg": "",
        "error_code": 0,
        "error_msg": "",
        "media_info_list": null,
        "msg_id": "msg_id",
        "parameter": null
      },
      "media_info_list": [
        {
          "media_data": "https://obs-large.mtlab.meitu.com/mtopen/30f1b44ea57c4d94bbdfda14005b7332/e034c450-6ca4-4b2e-409d-b594a35cce50/e034c450-6ca4-4b2e-409d-b594a35cce50.mp4",
          "media_extra": null,
          "media_profiles": {
            "media_data_fps": 29.92023277282715,
            "media_data_height": 720,
            "media_data_size": 33731714,
            "media_data_type": "url",
            "media_data_width": 960
          }
        }
      ]
    },
    "progress": 1,
    "predict_elapsed": 10000,
    "create_time": 1765098852464,
    "task_id": "task_id",
    "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": "request_id",
  "trace_id": "trace_id",
  "code": 0,
  "error_code": 0,
  "message": "processing timeout",
  "tips": null,
  "data": {
    "status": 9,
    "result": {},
    "progress": 0,
    "predict_elapsed": 0,
    "create_time": 1765098852464,
    "task_id": "task_id",
    "custom_task_id": "",
    "trace_id": "trace_id",
    "client_info": "",
    "init_images": null
  }
}

Failed Response Example

Response Status: 400

Content-Type: application/json; charset=utf-8

{
  "request_id": "request_id",
  "trace_id": "trace_id",
  "code": 20001,
  "error_code": 20001,
  "message": "PROCESS_ERROR",
  "tips": null,
  "data": {
    "status": 2,
    "result": {
      "ErrorCode": 20001,
      "ErrorMsg": "PROCESS_ERROR",
      "Data": null
    },
    "progress": 0,
    "predict_elapsed": 0,
    "create_time": 1765098852464,
    "task_id": "task_id",
    "custom_task_id": "",
    "trace_id": "trace_id",
    "client_info": "",
    "init_images": null
  }
}

General Error Codes and Messages

See API Error Codes.

SDK Examples

Python

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": {
            "userboxes": "[[[0, 0.5], [1, 0.5], [1, 0.8], [0, 0.8]]]"
        },
    }
    payload = {
        "task": "/v1/videosubtitle_remove/485023",
        "task_type": "formula",
        "init_images": [
            {
                "url": "https://xxx.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

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/videosubtitle_remove/485023",
  "task_type": "formula",
  "init_images": [{
    "url": "https://xxx.mp4",
    "profile": {
      "media_profiles": {"media_data_type": "url"},
      "version": "v1"
    }
  }],
  "params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"userboxes\":\"[[[0, 0.5], [1, 0.5], [1, 0.8], [0, 0.8]]]\"}}",
  "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

<?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' => [
        'userboxes' => '[[[0, 0.5], [1, 0.5], [1, 0.8], [0, 0.8]]]',
    ],
]);

$body = json_encode([
    'task' => '/v1/videosubtitle_remove/485023',
    'task_type' => 'formula',
    'init_images' => [
        [
            'url' => 'https://xxx.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

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/videosubtitle_remove/485023\",\n" +
                "  \"task_type\": \"formula\",\n" +
                "  \"init_images\": [{\n" +
                "    \"url\": \"https://xxx.mp4\",\n" +
                "    \"profile\": {\n" +
                "      \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
                "      \"version\": \"v1\"\n" +
                "    }\n" +
                "  }],\n" +
                "  \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"userboxes\\\":\\\"[[[0, 0.5], [1, 0.5], [1, 0.8], [0, 0.8]]]\\\"}}\",\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);
        }
    }
}