Product Introduction
Product Features
Intelligent Scheduling
New Protocol Support
Back-to-Origin Control
Security Protection
Content Management
Media Processing
Before You Start
How to Use
Transcoding
Transmuxing
Video Encryption
Intelligent Transcoding
Editing
Video/Audio Splicing
Video/Audio Trimming
Video Cropping
Screenshot
Add Subtitles
Add Watermarks
Appendix
Quick Start
Domain Management
Origin Settings
Cache Settings
Cache Purge and Prefetch
HTTP/HTTPS Settings
Access Control
Advanced Settings
Logs and Reports
Tutorials

Add Subtitles

Last update:2025-03-21 15:32:55

Add subtitles to your videos with options for both hardcoded (permanent) and softcoded (viewer-selectable) subtitle tracks.

Supported Formats

  • Input Videos: MP4, FLV, M3U8, TS, MKV, MOV, WMV, AVI, VP8, VP9, RealVideo, Windows Media Video, and more
  • Codecs: H.265, H.264, H.263, MPEG, and more
  • Subtitle Formats: SRT, MKV subtitles, embedded subtitle streams

How to Use

Structure your fops command as shown below:

<op>/<Format>
    /subtitle/<value>
    /subtitleType/<value>
    /subtitleAttr/<value>
    |saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Parameters

Parameter Required Description
op Yes Operation type. Use avthumb for subtitle operations.
format Yes Target output format (mp4, flv, m3u8, etc.)
subtitle Yes The subtitle file(s) to embed, URL-safe Base64 encoded in the format bucket:path

Supported subtitle sources:
• SRT files (UTF-8 encoded)
• Subtitles extracted from MKV files
• Embedded subtitle streams from the original video

Example: For a subtitle file 1.srt in bucket test, use test:1.srtdGVzdDoxLnNydA==

Multiple subtitles: Concatenate with commas
Example: subtitle=aHR0cDovL2VuY29kZS5jaGFodW8uY29tLw,aHR0cDovL2VuY29kZS5jaGFodW8uY29tLw
subtitleType No How subtitles are incorporated:
0 (Default) - Automatic selection based on system recognition
1 - Softcoded: Can be toggled on/off by viewers
2 - Hardcoded: Permanently embedded into the video
subtitleAttr No Attributes for softcoded subtitles in adaptive bitrate (m3u8) output

Format: subtitleAttr=base64_encode(lang=xx1,name=yy1)
lang - Language code attribute
name - Subtitle name or description

Multiple attributes: Separate with commas
Example: subtitleAttr=base64_encode(lang=en,name=English),base64_encode(lang=es,name=Spanish)

Important: The number of subtitleAttr values must match exactly with the number of subtitle files
saveas No Output location as URL-safe Base64-encoded string: Urlsafe_Base64_Encode(bucket:savedfilename)

Example

This example adds subtitles from zimu.srt to the test.flv video file in the vod-wcs-test001 bucket. The video is converted to MP4 format and stored as test_file.mp4:

Pseudocode:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.flv)&fops=Urlsafe_Base64_Encode(avthumb/mp4/subtitle/Urlsafe_Base64_Encode(vod-wcs-test001:zimu.srt)|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.mp4))&force=1&separate=1" 
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual Request:

curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5mbHY=&fops=YXZ0aHVtYi9tcDQvc3VidGl0bGUvZG05a0xYZGpjeTEwWlhOME1EQXhPbnBwYlhVdWMzSjBDZz09fHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXRjRFFLQ2c9PQ==&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!