Add Subtitles

Last update:2026-07-15 18:53:04

Add subtitles to your videos with support 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, and 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, such as mp4, flv, or m3u8.
subtitle Yes 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: Separate multiple values with commas.
Example: subtitle=aHR0cDovL2VuY29kZS5jaGFodW8uY29tLw,aHR0cDovL2VuY29kZS5jaGFodW8uY29tLw
subtitleType No Specifies how subtitles are added:
0 (default) - Automatically selected based on system recognition
1 - Softcoded: Viewers can turn subtitles on or off
2 - Hardcoded: Permanently burned 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
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 exactly match the number of subtitle files.
saveas Yes Output location as a URL-safe Base64-encoded string, in the format Urlsafe_Base64_Encode(bucket:savedfilename).

Example

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

Pseudocode:

curl -v -X POST \
  -d "bucket=Urlsafe_Base64_Encode(vod-test001)&key=Urlsafe_Base64_Encode(test.flv)&fops=Urlsafe_Base64_Encode(avthumb/mp4/subtitle/Urlsafe_Base64_Encode(vod-test001:zimu.srt)|saveas/Urlsafe_Base64_Encode(vod-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"