SuperAPI AI Directory

tencent-mps

Writing & research

View repository

Updated 10-15 23:59

About this skill

Tencent Cloud Media Processing Service (MPS)

💰 Cost Notice: This Skill calling Tencent Cloud MPS service will incur corresponding costs, including transcoding fees, AI processing fees, storage fees, etc. For specific billing standards, please refer to Tencent Cloud MPS Pricing. Every time the media processing/image processing/image generation/video generation features of MPS are used, a notice must be given.

Call the MPS API through the official Tencent Cloud Python SDK. All scripts are located in the scripts/ directory and all support --help and --dry-run。

Detailed Parameters: See references/params.md Complete Example Set: See references/scripts-detail.md

Environment Configuration

Check environment variables:

python scripts/load_env.py --check-only

Configuration (~/.profile or ~/.bashrc):

# 必须(所有脚本)
export TENCENTCLOUD_SECRET_ID="your-secret-id"
export TENCENTCLOUD_SECRET_KEY="your-secret-key"

# 以下场景必须配置 COS 变量:
#   1. 输入源为 --cos-object(即 COS 对象路径,非 URL)
#   2. 使用 mps_cos_upload.py / mps_cos_download.py 上传/下载本地文件
#   3. 脚本需要将处理结果写回 COS(OutputStorage)
export TENCENTCLOUD_COS_BUCKET="your-bucket"        # COS 存储桶名
export TENCENTCLOUD_COS_REGION="your-bucket-region" # 存储桶地域,如 ap-guangzhou

Install dependencies:

pip install tencentcloud-sdk-python cos-python-sdk-v5

Local File Processing Workflow

MPS only accepts URLs or COS objects as input;local files must be uploaded first。

Automatic Processing Workflow When the User Inputs a Local File

When the user's request involves a local file path (such as ./video.mp4、/path/to/image.jpg), follow the steps below toautomatically process:

Step 1: Upload the file to COS

python scripts/mps_cos_upload.py --local-file <本地文件路径> --cos-key <目标路径>
  • Use --cos-key to specify a reasonable storage path (default path input/)
  • Record the COS information returned by the upload: bucket, region, key

Step 2: Run the script using COS path parameters Depending on the script type, use the method for passing the COS path in each script, as follows:

Script COS Path Parameter Method Example
mps_transcode.py --cos-object <key> --cos-object input/video.mp4
mps_enhance.py --cos-object <key> --cos-object input/video.mp4
mps_erase.py --cos-object <key> --cos-object input/video.mp4
mps_subtitle.py --cos-object <key> --cos-object input/video.mp4
mps_imageprocess.py --cos-object <key> --cos-object input/image.jpg
mps_qualitycontrol.py --cos-object <key> --cos-object input/video.mp4
mps_av_understand.py --cos-object <key> --cos-object input/video.mp4
mps_vremake.py --cos-object <key> --cos-object input/video.mp4
mps_narrate.py --cos-object <key> --cos-object input/video.mp4
mps_highlight.py --cos-object <key> --cos-object input/video.mp4
mps_aigc_image.py --cos-input-bucket <b> --cos-input-region <r> --cos-input-key <k> --cos-input-bucket xxx --cos-input-region ap-guangzhou --cos-input-key input/img.jpg
mps_aigc_video.py --cos-input-bucket <b> --cos-input-region <r> --cos-input-key <k> --cos-input-bucket xxx --cos-input-region ap-guangzhou --cos-input-key input/img.jpg

Note: Scripts that use --cos-object depend on the environment variables TENCENTCLOUD_COS_BUCKET and TENCENTCLOUD_COS_REGION; AIGC-type scripts need to explicitly pass the complete COS information.

Step 3: Download the processing result (if needed)

python scripts/mps_cos_download.py --cos-key <输出key> --local-file <本地保存路径>

Input Method Description

Depending on the input source, two methods are supported:

Method 1: COS Path Method (recommended for locally uploaded files)

Use the --cos-object <key> parameter (or --cos-input-bucket/--cos-input-region/--cos-input-key)

  • Applicable scenario: processing after the user uploads a local file to COS
  • Reason: Locally uploaded files may not have public read permission, and using the URL directly may fail
  • Example:--cos-object input/video.mp4

Method 2: URL Method (applicable to existing URLs)

Use the --url <url> parameter

  • Applicable scenario: the user directly provides a file URL (including COS URLs from other accounts/sources, external links, etc.)
  • Requirement: The URL must be publicly accessible or already carry a valid signature
  • Example:--url https://example-bucket.cos.ap-guangzhou.myqcloud.com/video.mp4

⚠️ Note: If the URL comes from a locally uploaded COS file and does not have public permission, please use Method 1 (COS path method); the script will automatically generate a signed URL.

Manual Processing Example

If manual execution is needed, the complete workflow is as follows:

# 1. 上传
python scripts/mps_cos_upload.py --local-file ./video.mp4 --cos-key input/video.mp4
# 2. 执行任务(使用 COS 路径)
python scripts/mps_transcode.py --cos-object input/video.mp4
# 3. 下载结果
python scripts/mps_cos_download.py --cos-key output/result.mp4 --local-file ./result.mp4

When the returned result contains a link, return it to the user in Markdown format:[文件名](URL)

Asynchronous Task Description

All scripts automatically poll and wait for completion by default.

  • Submit only without waiting: add --no-wait, the script returns TaskId
  • Manual query: for audio/video use mps_get_video_task.py, for images use mps_get_image_task.py

Script Function Mapping (Responsibility Boundaries)

💰 The following operations will call the Tencent Cloud MPS service and incur charges.

When selecting a script, you must strictly follow the mapping relationship,do not mix them up:

User Requirement Type Script Used Description
Check image quality, detect blurriness/screen artifacts mps_qualitycontrol.py The only quality inspection script,--definition 60(default)
Detect playback compatibility, stuttering, playback anomalies mps_qualitycontrol.py The only quality inspection script,--definition 70
Audio quality detection, audio event detection mps_qualitycontrol.py The only quality inspection script,--definition 50
Remove subtitles, erase watermarks, face/license plate blurring mps_erase.py Only used for erasing/masking image content
Image quality enhancement, old film restoration, super-resolution mps_enhance.py Video image quality improvement
Transcoding, compression, format conversion mps_transcode.py Encoding format processing
Subtitle extraction, translation, subtitle-related speech recognition mps_subtitle.py Subtitle-related
Image processing (super-resolution/beautification/denoising) mps_imageprocess.py Image enhancement
AI image generation (text-to-image/image-to-image) mps_aigc_image.py AIGC image generation
AI video generation (text-to-video/image-to-video/storyboard generation) mps_aigc_video.py AIGC video generation,the Kling model supports the storyboard feature
Audio/video content understanding (scene/summary/analysis/speech recognition) mps_av_understand.py Large model understanding,must provide --mode and --prompt
Video deduplication (picture-in-picture/video extension/face swap/person swap, etc.) mps_vremake.py VideoRemake,must provide --mode
Usage statistics query mps_usage.py Call count/duration query
AI commentary re-creation / short drama commentary / automatic short drama commentary video generation / short drama commentary mashup mps_narrate.py must be selected from the preset --scene ; custom scripts are not supported; multi-episode videos are added in order via --extra-urls append
Highlights / highlight extraction / automatic editing of highlight clips / football goal highlights / basketball highlights / short drama highlights mps_highlight.py must be selected from the preset --scene ; manually assembling ExtendedParameter is prohibited; live streams are not supported
Query audio/video processing task status mps_get_video_task.py ProcessMedia task query
Query image processing task status mps_get_image_task.py ProcessImage task query
Upload local files to COS mps_cos_upload.py Local→COS preliminary step
Download files from COS mps_cos_download.py COS→Local follow-up step
List COS Bucket files mps_cos_list.py View the COS file list, supports path filtering and filename search

Important:mps_erase.py The responsibility iserasing/masking visual elements in the image, does not involve quality detection. "Quality detection", "blur", "screen corruption", "playback compatibility", "audio quality inspection" → must use mps_qualitycontrol.py。

Mandatory rules for generating commands

  1. Script path prefix: all generated python commands must include the scripts/ path prefix, in the format python scripts/mps_xxx.py .... It is forbidden to generate python mps_xxx.py ...(missing the scripts/ prefix) commands.

  2. No placeholders: all parameter values must be real values. If the user does not provide a required value,ask first, and do not use <视频URL>、YOUR_URL or other placeholders.

  3. mps_qualitycontrol.py must include --definition:

    • Audio quality inspection:--definition 50
    • Picture quality inspection (default):--definition 60
    • Playback compatibility:--definition 70
  4. mps_av_understand.py must include --mode and --prompt:

    • --mode video(understand video frames) or --mode audio(audio only, audio is automatically extracted from video)
    • --prompt controls the focus of the large model's understanding; if missing, the result may be empty
  5. mps_narrate.py must include --scene:

    • The value must be one of the preset enums:short-drama | short-drama-no-erase
    • When the user says "has subtitles"/"with hard subtitles", default to selecting the scene that includes erasure (short-drama)
    • When the user says "no subtitles"/"original video has no subtitles"/"no erasure", select -no-erase scene (short-drama-no-erase)
    • For multi-episode videos, use --url/--cos-objectfor the first episode, and use --extra-urls for subsequent episodes, appending in order
    • It is forbidden to pass in scriptUrls related parameters (custom script input is not supported this time)
  6. mps_highlight.py must include --scene:

    • The value must be one of the preset enums:vlog | vlog-panorama | short-drama | football | basketball | custom
    • When the user mentions keywords such as "basketball"/"football"/"short drama"/"VLOG", map directly to the corresponding --scene, no need to ask again
    • --prompt and --scenario only take effect when --scene custom , but neither is required
    • --top-clip is only allowed in vlog / vlog-panorama / custom scenarios
    • It is forbidden to generate ExtendedParameter fields or values outside the preset table
    • When the user requests processing live stream highlights, inform them that the current skill does not support live streams and that the MPS API must be used directly

Key script descriptions

Video enhancement (mps_enhance.py)

Large model enhancement template (--template), select by scenario + target resolution:

Scenario 720P 1080P 2K 4K
Real people (Real) 327001 327003 327005 327007
Anime (Anime) 327002 327004 327006 327008
Jitter optimization 327009 327010 327011 327012
Strongest detail 327013 327014 327015 327016
Face fidelity 327017 327018 327019 327020

Subtitle removal erasure (mps_erase.py)

Preset templates:101 subtitle removal | 102 subtitle removal + OCR | 201 watermark removal advanced version | 301 face blur | 302 face + license plate blur

Large model audio-video understanding (mps_av_understand.py)

Controlled via AiAnalysisTask.Definition=33 + ExtendedParameter(mvc.mode + mvc.prompt) .

# 视频内容理解
python scripts/mps_av_understand.py \
    --url https://example.com/video.mp4 \
    --mode video \
    --prompt "请分析这个视频的主要内容、场景和关键信息"

# 音频模式(视频自动提取音频)
python scripts/mps_av_understand.py \
    --url https://example.com/video.mp4 \
    --mode audio \
    --prompt "请进行语音识别,输出完整文字内容"

# 对比分析(两段音视频)
python scripts/mps_av_understand.py \
    --url https://example.com/v1.mp4 \
    --extend-url https://example.com/v2.mp4 \
    --mode audio \
    --prompt "对比两段音频,分析差异"

# 查询任务
python scripts/mps_av_understand.py --task-id 2600011633-WorkflowTask-xxxxx --json

Media quality inspection (mps_qualitycontrol.py)

The script supports the following 3 system preset templates (--definition parameter):

Preset templates:

  • 60(default): Format Quality Inspection-Pro version, detects content issues such as blurry images, screen corruption, and damaged frames
  • 50: Audio Detection, audio quality/audio event detection
  • 70: Content Quality Inspection - Pro Edition, detects playback stuttering, playback anomalies, and playback compatibility issues
# 画面质检(默认,使用预设模板 60)
python scripts/mps_qualitycontrol.py --url https://example.com/video.mp4 --definition 60

# 播放兼容性质检(预设模板 70)
python scripts/mps_qualitycontrol.py --url https://example.com/video.mp4 --definition 70

# 音频质检(预设模板 50)
python scripts/mps_qualitycontrol.py --url https://example.com/audio.mp3 --definition 50

# 异步提交
python scripts/mps_qualitycontrol.py --url https://example.com/video.mp4 --definition 60 --no-wait

Video Deduplication (mps_vremake.py)

# 画中画去重(等待结果)
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode PicInPic --wait

# 视频扩展去重
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode BackgroundExtend --wait

# 换脸模式
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode SwapFace \
    --src-faces https://example.com/src.png --dst-faces https://example.com/dst.png --wait

# 换人模式
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode SwapCharacter \
    --src-character https://example.com/src_full.png \
    --dst-character https://example.com/dst_full.png --wait

# 画中画 + LLM 提示词
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode PicInPic \
    --llm-prompt "生成一个唯美的自然风景背景图片" --wait

# 异步提交(默认,不加 --wait)
python scripts/mps_vremake.py --url https://example.com/video.mp4 --mode PicInPic

# 查询任务
python scripts/mps_vremake.py --task-id 2600011633-WorkflowTask-xxxxx --json

Deduplication Mode:PicInPic(Picture-in-Picture)BackgroundExtend(Video Extension)VerticalExtend(Vertical Fill)HorizontalExtend(Horizontal Fill)AB(Video Interleaving)SwapFace(Face Swap)SwapCharacter(Person Swap)
Main Parameters:--url / --cos-object / --task-id / --mode(Required) / --wait / --llm-prompt / --llm-video-prompt / --src-faces+--dst-faces(Face Swap) / --src-character+--dst-character(Person Swap) / --json / --dry-run

AI Commentary Secondary Creation (mps_narrate.py)

Input the original video, and complete commentary script generation, script matching into a finished video, AI voiceover, subtitle removal, and other operations automatically in one stop, outputting a new video with commentary copy, voiceover, and subtitles.

# 短剧单集解说(默认含擦除,输出1个视频)
python scripts/mps_narrate.py --url https://example.com/drama.mp4 --scene short-drama

# COS对象输入
python scripts/mps_narrate.py --cos-object /input/drama.mp4 --scene short-drama

# 原视频无字幕,关闭擦除
python scripts/mps_narrate.py --url https://example.com/drama.mp4 --scene short-drama-no-erase

# 短剧三集合并解说,输出3个不同版本
python scripts/mps_narrate.py \
    --url https://example.com/ep01.mp4 \
    --extra-urls https://example.com/ep02.mp4 https://example.com/ep03.mp4 \
    --scene short-drama \
    --output-count 3

# Dry Run(预览转义后的 ExtendedParameter)
python scripts/mps_narrate.py --url https://example.com/drama.mp4 --scene short-drama --dry-run

Preset Scenarios:short-drama(Short drama, with erasure) | short-drama-no-erase(Short drama, without erasure)
Main Parameters:--url / --cos-object(Episode 1, required) / --scene(Required) / --extra-urls(From Episode 2) / --output-count(Output quantity, default 1, maximum 5) / --no-wait / --dry-run

Highlights (mps_highlight.py)

Use the MPS intelligent analysis feature to automatically capture and generate highlight clips (highlight reels) from videos through AI algorithms. It uses preset template No. 26 by default and supports multiple scenarios such as VLOG, short dramas, football matches, and basketball matches.

# 足球赛事精彩集锦
python scripts/mps_highlight.py --cos-object /input/football.mp4 --scene football

# 短剧影视高光
python scripts/mps_highlight.py --cos-object /input/drama.mp4 --scene short-drama

# VLOG 全景相机
python scripts/mps_highlight.py --url https://example.com/vlog.mp4 --scene vlog-panorama

# 自定义场景(大模型版)
python scripts/mps_highlight.py --url https://example.com/skiing.mp4 \
    --scene custom --prompt "滑雪场景,输出人物高光" --scenario "滑雪"

# 篮球赛事
python scripts/mps_highlight.py --cos-object /input/basketball.mp4 --scene basketball

# 指定输出片段数(仅 vlog/vlog-panorama/custom 支持)
python scripts/mps_highlight.py --cos-object /input/vlog.mp4 --scene vlog --top-clip 10

# Dry Run(仅打印请求参数)
python scripts/mps_highlight.py --cos-object /input/game.mp4 --scene football --dry-run

Preset Scenarios:

  • vlog: VLOG, scenery, drone videos (large model version)
  • vlog-panorama: Panoramic camera (enable panoramic optimization, large model version)
  • short-drama: Short dramas, film and television dramas, extract highlights of the protagonist's appearance/BGM (large model version)
  • football: Football matches, identify shots/goals/red and yellow cards/replays (advanced version)
  • basketball: Basketball matches (advanced version)
  • custom: Custom scenario, can pass --prompt and --scenario(large model version)

Main Parameters:--url / --cos-object(Required) / --scene(Required) / --prompt(custom scenario) / --scenario(custom scenario) / --top-clip(available for vlog/vlog-panorama/custom scenarios) / --no-wait / --dry-run

⚠️ Important Restrictions:

  • This script only supports processing offline files and does not support live streams
  • --top-clip Only allowed in the vlog / vlog-panorama / custom scenario
  • --prompt and --scenario only take effect when --scene custom , but neither is required
  • ExtendedParameter must be selected from the preset scenario parameters; assembling it yourself is prohibited

Usage Statistics (mps_usage.py)

python scripts/mps_usage.py --days 30 --all-types
python scripts/mps_usage.py --start 2026-01-01 --end 2026-01-31
python scripts/mps_usage.py --type Transcode Enhance AIGC AIAnalysis

--type Supports:Transcode Enhance AIAnalysis AIRecognition AIReview Snapshot AnimatedGraphics AiQualityControl Evaluation ImageProcess AddBlindWatermark AddNagraWatermark ExtractBlindWatermark AIGC

API Reference

Script Documentation
mps_transcode.py / mps_enhance.py / mps_subtitle.py / mps_erase.py ProcessMedia
mps_qualitycontrol.py ProcessMedia AiQualityControlTask
mps_imageprocess.py ProcessImage
mps_av_understand.py VideoComprehension AiAnalysisTask
mps_vremake.py VideoRemake AiAnalysisTask
mps_narrate.py ProcessMedia AiAnalysisTask
mps_highlight.py ProcessMedia AiAnalysisTask
mps_aigc_image.py CreateAigcImageTask
mps_aigc_video.py CreateAigcVideoTask
mps_usage.py DescribeUsageData
mps_get_video_task.py DescribeTaskDetail
mps_get_image_task.py DescribeImageTaskDetail