Skip to main content

A small package and CLI for manipulating and creating subtitles (SubRip, .srt, etc.)

Project description

Pyzub: Manipulate subtitles

Pyzub is a small package and CLI for manipulating subtitles

Suported Formats:

  • SubRip [.srt].

Plans to Support:

  • SubStation Alpha [.ssa]
  • SubViewer [.sub]
  • Universal Subtitle Format [.usf]


Run pip install pyzub

Command Line Interface:

At the moment only the slide command is available (arguably the most important feature). The slide command of pyzub lets you move your subtitles so you can synchronize them manually.

$ pyzub slide -h
Usage: pyzub slide [OPTIONS] FILEPATH

  --hours FLOAT
  --minutes FLOAT
  --seconds FLOAT
  --milliseconds FLOAT
  --microseconds FLOAT
  --overwrite           Modifies the subtitle file in place.
  --verbose             Displays a progress bar and a message when finished.
  --help, -h            Show this message and exit.


This will move your subtitles by 2.5 seconds (you can also give negative values):

$ pyzub slide --seconds 2 --milliseconds 500

By default pyzub will generate an output file named, unless --overwrite is used. The output file will always be in utf-8 encoding and use your system new line character.

This is OK too:

$ pyzub slide --seconds -70.5 --milliseconds 5000

This would move your subtitles 65.5 seconds back in time.


You can read a subtitle file:

from pyzub.subfiles import SRTFile

filepath = '/home/user/'
subfile = SRTFile(filepath)

Iterate over the file:

for subtitle in subfile:

Print a SRTFile:

Relative Path: /home/user/
Codec: ISO-8859-1
No. of Subtitles: 451

Get a subtitle:

# idx could be a number from 1 to 451 in this case
subtitle = subfile.get_subtitle(idx)

Print the subtitle:

Index: 1
Start Time: 00:00:04,605
End Time: 00:00:06,105
Text: En un día cualquiera,

An of course modify anything you want directly:

# modify the text
subtile.text = 'modified subtitle'

# times use timedelta from the datetime package
subtitle.start_time = timedelta(minutes=10)
# also, you can assign directly a string
subtitle.end_time = '01:25:59,650'

# write the changes to disk

And finally:

# output: 451 (i.e, the number of subtitles in the file)
# output: 21 (i.e, the number of chars in the subtitle's text attribute)

Planned features:

  • Insert, delete subtitles, etc.
  • Automatic grammar and syntax correction



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzub-0.1.6.tar.gz (5.2 kB view hashes)

Uploaded source

Built Distribution

pyzub-0.1.6-py3-none-any.whl (6.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page