PYSUBS2(1)
π pysubs2 π
okay bestie, gather round, because this is the glow-up your subtitle files have been waiting for π
pysubs2</purpose> β a command-line tool to convert and retime subtitle files. that's it, that's the whole vibe, and it ate. β¨
β¨ DESCRIPTION β¨
here's the whole usage situation, copied exactly because we do NOT play with flags around here:
usage: pysubs2 [-h] [-v] [-f {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt}]
[-t {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt}] [--input-enc ENCODING] [--output-enc ENCODING] [--enc-error-handling {strict,surrogateescape}] [--fps FPS] [-o DIR] [--clean]
[--verbose] [--shift TIME | --shift-back TIME | --transform-framerate FPS1 FPS2] [--srt-keep-unknown-html-tags] [--srt-keep-html-tags] [--srt-keep-ssa-tags]
[--sub-no-write-fps-declaration] [FILE ...]
The pysubs2 CLI for processing subtitle files.
https://github.com/tkarabela/pysubs2 β go follow the source, it's iconic π
πΈ positional arguments πΈ
FILEβ your input subtitle files, bestie. they can be in SubStation Alpha (*.ass,*.ssa), SubRip (*.srt), MicroDVD (*.sub) or any other supported format. and here's the cute part: if you don't name any files at all,pysubs2goes full pipe mode β it reads from standard input and writes to standard output. main character energy fr fr π«Ά
π options π
-h,--helpβ shows this help message and dips. classic. β¨-v,--versionβ prints the program's version number and exits. short and sweet, no cap.-f {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt},--from {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt}β by default, the subtitle format is detected straight from the file. this option lets you skip autodetection and force a specific format. ngl, generally you should never need it. it's giving "emergency button" π-t {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt},--to {srt,ass,ssa,microdvd,json,mpl2,tmp,vtt}β converts subtitle files to the given format. by default, each file is saved in its original format. lowkey the whole point of the tool π--input-enc ENCODINGβ character encoding for input files. by default, UTF-8 is used for both input and output. simple, clean, obsessed π--output-enc ENCODINGβ character encoding for output files. by default it's the same as the input encoding. β οΈ real talk though: if you wanna convert between encodings, make sure--input-encis set correctly! otherwise your output files will probably be corrupted. it's a genuinely good idea to back up your files or use the-ooption. don't be the girl who loses her subs π--enc-error-handling {strict,surrogateescape}β character encoding error handling for input and output. defaults to'surrogateescape', which passes through unrecognized characters to output unchanged. use'strict'if you want the command to fail when it hits a character that's incompatible with the selected input/output encoding. pick your fighter β--fps FPSβ this argument specifies framerate for MicroDVD files. by default, framerate is detected from the file. use this when the framerate spec is missing, or when you want to force a different framerate. π¦-o DIR,--output-dir DIRβ use this to save all files to the given directory. by default, every file is saved to its parent directory, ie. unless it's being saved in a different subtitle format (and thus with a different file extension), it overwrites the original file. just so you know. π--cleanβ attempts to remove non-essential subtitles (eg. karaoke, SSA drawing tags), and strips styling information when saving to non-SSA formats. decluttering, we love to see it β¨--verboseβ prints misc logging. chatterbox mode, but make it useful π¬--shift TIMEβ delays all subtitles by the given time amount. time is specified like this:'1m30s','0.5s', ... π--shift-back TIMEβ the opposite of--shift(subtitles will appear sooner). rewind era π«--transform-framerate FPS1 FPS2β multiplies all timestamps by theFPS1/FPS2ratio. math girlies rise π₯
π optional arguments (SRT) π
--srt-keep-unknown-html-tagsβ (input) do not strip unrecognized HTML tags. π«Ά--srt-keep-html-tagsβ (input) do not convert HTML tags to SubStation internally; this implies--srt-keep-unknown-html-tags. chain reaction, iconic π--srt-keep-ssa-tagsβ (output) do not convert/strip SubStation tags for output. πΈ
π optional arguments (MicroDVD) π
--sub-no-write-fps-declarationβ (output) omit writing FPS as the first zero-length subtitle. bye bye little declaration line π
π usage examples π
the moment you've all been waiting for β copy these, run these, slay:
python -m pysubs2 --to srt *.ass
python -m pysubs2 --to srt --clean *.ass
python -m pysubs2 --to microdvd --fps 23.976 *.ass
python -m pysubs2 --shift 0.3s *.srt
python -m pysubs2 --shift 0.3s <my_file.srt >retimed_file.srt
python -m pysubs2 --shift-back 0.3s --output-dir retimed *.srt
python -m pysubs2 --transform-framerate 25 23.976 *.srt
see? retiming, converting, piping, all of it. you're basically a wizard now π§
π¦ SEE ALSO π¦
The full documentation for pysubs2 is maintained as a Texinfo manual. If the info and pysubs2 programs are properly installed at your site, the command
info pysubs2
should give you access to the complete manual. go read the lore, iykyk πβ¨
and that's the whole page, bestie! this is pysubs2 1.7.1, from June 2024, manual section 1, User Commands β so if you see that version and date floating around, you know exactly where you are. stay converted, stay retimed, mwah ππ
π¦ where this page comes from
- debian trixie: pysubs2 1.8.0-1 Β· MIT
- ubuntu resolute: pysubs2 1.8.0-1 Β· MIT
- ubuntu stonking: pysubs2 1.8.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms