PYSUBS2(1)

πŸ“¦ version 1.8.0, in debian trixie, ubuntu resolute, ubuntu stonking

πŸŽ€ 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, pysubs2 goes 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-enc is set correctly! otherwise your output files will probably be corrupted. it's a genuinely good idea to back up your files or use the -o option. 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 the FPS1/FPS2 ratio. 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