Skip to main content

Subtext

Subtext is a subtitle renderer that uses libass and ffmpeg.

.. function:: TextFile(clip clip, string file[, string charset="UTF-8", float scale=1, int debuglevel=0, string fontdir="", float linespacing=0, int[] margins=[0, 0, 0, 0], float sar=0, string style="", bint blend=True, int matrix, string matrix_s, int transfer, string transfer_s, int primaries, string primaries_s]) :module: sub

TextFile renders text subtitles. Supported formats include ASS, JACOsub, MicroDVD, SAMI, SRT, WebVTT, and some other obscure ones.

TextFile has two modes of operation. With blend=True (the default), it returns clip with the subtitles burned in. With blend=False, it returns an RGB24 clip containing the rendered subtitles, with a Gray8 frame attached to each frame in the _Alpha frame property. These Gray8 frames can be extracted using std.PropToClip.

Parameters: clip Input clip. It must have a constant format, constant dimensions, and a constant frame rate.

  file
     Subtitle file to be rendered.

  charset
     Character set of the subtitle, in iconv format.

  scale
     Font scale.

  debuglevel
     Debug level. Increase to make libass more chatty.
     See `ass_utils.h <https://github.com/libass/libass/blob/master/libass/ass_utils.h>`_
     in libass for the list of meaningful values.

  fontdir
     Directory with additional fonts.

  linespacing
     Space between lines, in pixels.

  margins
     Additional margins, in pixels. Negative values are not
     allowed. The order is top, bottom, left, right.

  sar
     Sample aspect ratio, also known as the pixel aspect ratio: the
     ratio of the width of a pixel to its height. 1 means square
     pixels.

     By default this follows the ``_SARNum`` and ``_SARDen`` frame
     properties of *clip*, individually for every frame, so
     anamorphic video gets subtitles that look right once the video
     is displayed at its intended shape. Frames without those
     properties are treated as having square pixels.

     Setting it uses the given ratio for every frame instead. That
     also means no frame of *clip* has to be looked at, which is
     worth doing when blend=False and producing the frames of *clip*
     is expensive.

  style
     Custom ASS style for subtitle formats other than ASS. If empty
     (the default), libavcodec's default style is used. This
     parameter has no effect on ASS subtitles.

  blend
     If True, the subtitles will be blended into *clip*. Otherwise,
     the bitmaps will be returned untouched.

  matrix

  matrix_s

  transfer

  transfer_s

  primaries

  primaries_s
     Overrides for the colorimetry of *clip*. Only used when
     blend=True, and only needed when *clip* is tagged wrongly or
     not at all.

     By default the subtitles are converted to match *clip*, frame
     by frame, following its ``_Matrix``, ``_Transfer``,
     ``_Primaries``, ``_ColorRange`` and ``_ChromaLocation`` frame
     properties. The subtitles are treated as BT.709 to start with,
     so a frame tagged as, say, PQ and BT.2020 gets subtitles
     converted into that colour space instead of blended in as if
     they were already in it. A frame that says nothing usable is
     handled the way it always was: the BT.709 matrix and no colour
     space conversion. The colour range is always taken from *clip*
     and can't be overridden, because the two can only be blended
     when they agree on it.

     These are worth reaching for in two cases:

     Untagged clips. Nothing can be adapted to, so the subtitles
     fall back to BT.709. Standard definition material is the usual
     victim, and ``matrix_s="470bg"`` is the usual answer.
     Tagging the clip with std.SetFrameProps instead is generally
     better, since that fixes everything downstream and not just
     the subtitles.

     Turning the colour space conversion off. Passing
     ``transfer=1, primaries=1`` converts the subtitles from BT.709
     to BT.709, which does nothing, so they end up blended in
     unconverted the way they were before this was done per frame.
     Both are needed, since either one on its own still leaves the
     other being adapted to.

.. function:: Subtitle(clip clip, string text[, int start=0, int end=clip.numFrames, int debuglevel=0, string fontdir="", float linespacing=0, int[] margins=[0, 0, 0, 0], float sar=0, string style="sans-serif,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,7,10,10,10,1", bint blend=True, int matrix, string matrix_s, int transfer, string transfer_s, int primaries, string primaries_s]) :module: sub

Instead of rendering a subtitle file, Subtitle renders the string text. Otherwise it works the same as TextFile.

Parameters: text String to be rendered. This can include ASS tags to enable rich text and animation.

  style
     Custom ASS style to be used.
  
  start, end
     Subtitle will be shown from *start* up until *end*. By default this will be for all frames in *clip*.

The other parameters have the same meanings as with TextFile.

.. function:: ImageFile(clip clip, string file[, int id=-1, int[] palette, bint gray=False, bint info=False, bint flatten=False, bint blend=True, int matrix, string matrix_s, int transfer, string transfer_s, int primaries, string primaries_s]) :module: sub

ImageFile renders image-based subtitles such as VOBSUB and PGS.

Parameters: clip If blend is True, the subtitles will be burned into this clip, Otherwise, only the frame rate and number of frames will be obtained from this clip.

     It must have a constant format, constant dimensions, and a
     constant frame rate, even when *blend* is False.

  *file*
     Name of the subtitle file. For VOBSUB, it must the name of the
     idx file. The corresponding sub file must be in the same
     folder, and it must have the same name.

  *id*
     Id of the subtitle track to render. There may be several
     subtitle tracks in the same file. If this is -1, the first
     supported subtitle track will be rendered. Use info=True to
     see a list of all subtitle tracks, including their ids.

     Default: -1.

  *palette*
     Custom palette. This is an array of at most 256 integers. Each
     element's least significant four bytes must contain the values
     for alpha, red, green, and blue, in that order, from most
     significant to least.

     Additionally, the special value 2**42 means that the
     corresponding element of the original palette is used. This
     way it is possible to override only the third element, without
     overriding the first and second ones, for example.

     An alpha value of 255 means the colour will be completely
     opaque, and a value of 0 means the colour will be completely
     transparent.

  *gray*
     If True, the subtitles will be turned gray.

     Default: False.

  *info*
     If this is True, a list of all supported subtitle tracks found
     in the file will be printed on each frame of the output. The
     information printed about each track includes the id, the
     language (if known), the resolution, and the format.

     Default: False.

  *flatten*
     If this is True, ImageFile will output a clip with exactly as
     many frames as there are pictures in the subtitle file.

     If this is True, *blend* has no effect (no automatic blending).

     Default: False.

The other parameters have the same meanings as with TextFile.

Example with manual blending::

sub = core.sub.TextFile(clip=YUV420P10_video, file="asdf.ass", blend=False) mask = core.std.PropToClip(clip=sub, prop='_Alpha')

gray10 = core.query_video_format( mask.format.color_family, YUV420P10_video.format.sample_type, YUV420P10_video.format.bits_per_sample, mask.format.subsampling_w, mask.format.subsampling_h )

sub = core.resize.Bicubic(clip=sub, format=YUV420P10_video.format.id, matrix_s="470bg") mask = core.resize.Bicubic(clip=mask, format=gray10.id)

hardsubbed_video = core.std.MaskedMerge(clipa=YUV420P10_video, clipb=sub, mask=mask)

Example with automatic blending (will use BT709 matrix)::

hardsubbed_video = core.sub.TextFile(clip=YUV420P10_video, file="asdf.ass")

Example with a custom palette and automatic blending::

def rgba(r, g, b, a=255): if r < 0 or r > 255 or g < 0 or g > 255 or b < 0 or b > 255 or a < 0 or a > 255: raise vs.Error("Colours must be in the range [0, 255].")

   return (a << 24) + (r << 16) + (g << 8) + b

unused = 1 << 42

src = core.ffms2.Source("video.mp4")

Override only the third element of the palette. Set it to some kind of green.

ret = core.sub.ImageFile(src, "subtitles.sup", palette=[unused, unused, rgba(0, 192, 128)])

Metadata

Release files for vapoursynth-subtext 7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vapoursynth-subtext 7.0
File Size Uploaded
vapoursynth_subtext-7.0.tar.gz 32.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for vapoursynth-subtext 7.0
File
vapoursynth_subtext-7.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
vapoursynth_subtext-7.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
vapoursynth_subtext-7.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
vapoursynth_subtext-7.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
vapoursynth_subtext-7.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
vapoursynth_subtext-7.0-py3-none-macosx_15_0_x86_64.whl Python 3 none macOS 15.0+ x86-64 Details
vapoursynth_subtext-7.0-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details

Total release size: 72.7 MB

Release files / vapoursynth_subtext-7.0.tar.gz

Download URL vapoursynth_subtext-7.0.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
05147980c4db520bfe3e1d3dfe6c59f56138685d4f4332cd6124cf93dc369f9d
BLAKE2b-256 checksum
How to use checksums
04939d48992168e7ea36a85e197b86e5692c47b7d190421912c59d9cbebe3dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-win_amd64.whl

Download URL vapoursynth_subtext-7.0-py3-none-win_amd64.whl
Size 10.1 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
b8fe2c024d2f5d15eeb000ee7441105826ecd66d572615dbdfb8efb0e71e6b76
BLAKE2b-256 checksum
How to use checksums
7d683884378ad99b45479cbf991aee3ab9e43d1eeee8386e50dce817e4509aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-musllinux_1_2_x86_64.whl

Download URL vapoursynth_subtext-7.0-py3-none-musllinux_1_2_x86_64.whl
Size 12.3 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1c157c2dd5b60a9a05cfbca98782622dcae55f3cb2053bb90a19b3b440773691
BLAKE2b-256 checksum
How to use checksums
6e55707e6e1c683c3c18fdb38214df8359609f323acfd001e689e7c7672f29fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-musllinux_1_2_aarch64.whl

Download URL vapoursynth_subtext-7.0-py3-none-musllinux_1_2_aarch64.whl
Size 12.0 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
a401933250228bad97428df777d31f3f40d40308a091372cbaf3e6d01ade40a7
BLAKE2b-256 checksum
How to use checksums
e564f084fe2f2e553db0908f9316266be1f7d2428b99b359d399adbf7fe8dc99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-manylinux_2_28_x86_64.whl

Download URL vapoursynth_subtext-7.0-py3-none-manylinux_2_28_x86_64.whl
Size 10.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0e07aa42a7e78701b7aa2aace245e7bc6608fdae5eb981e8c2cf2c3f1055860f
BLAKE2b-256 checksum
How to use checksums
9c765280834705ebc7ca023cfc037ae2b931156fd2d62bb07c46e50b1d4bb0b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-manylinux_2_28_aarch64.whl

Download URL vapoursynth_subtext-7.0-py3-none-manylinux_2_28_aarch64.whl
Size 9.9 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
4d968cb2fa4f4f6db2ee189eca8e73f0666d31f6404124b26fcd1985a99d03f1
BLAKE2b-256 checksum
How to use checksums
465eaffc8b69458b64505a2abf8a4bb7b6c3f30aa89b95efeacfe6e9b02b5144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-macosx_15_0_x86_64.whl

Download URL vapoursynth_subtext-7.0-py3-none-macosx_15_0_x86_64.whl
Size 9.5 MB
Tags Python 3 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
9790c1f81e8d908628291408f8ce5fd84bb79db7e263791cda0a2143f7d37248
BLAKE2b-256 checksum
How to use checksums
feff3ce81eea55d792852a1a415c01309efd15111fb3cf585a9b2d90e627f7e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / vapoursynth_subtext-7.0-py3-none-macosx_15_0_arm64.whl

Download URL vapoursynth_subtext-7.0-py3-none-macosx_15_0_arm64.whl
Size 8.7 MB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f904b2951e25defc5c9698a867c8d1390bcdd461fa535152c0a44f6aef45d994
BLAKE2b-256 checksum
How to use checksums
7397b83c3d8f25c4c103bc50bb6bf9d0aacff64005f73f92df09f384af59777d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

7.0 This release

8 release files

6.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page