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.
Structure your fops
command as shown below:
<op>/<Format>
/subtitle/<value>
/subtitleType/<value>
/subtitleAttr/<value>
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>
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.srt → dGVzdDoxLnNydA== 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 descriptionMultiple 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) |
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"