All Projects → cdown → Srt

cdown / Srt

Licence: mit
A simple library for parsing, modifying, and composing SRT files.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Srt

Subtitle.js
Stream-based library for parsing and manipulating subtitle files
Stars: ✭ 234 (+11.43%)
Mutual labels:  srt, subtitles, subtitle
Ffsubsync
Automagically synchronize subtitles with video.
Stars: ✭ 5,167 (+2360.48%)
Mutual labels:  srt, subtitles, subtitle
Netflix To Srt
Rip, extract and convert subtitles to .srt closed captions from .xml/dfxp/ttml and .vtt/WebVTT (e.g. Netflix, YouTube)
Stars: ✭ 387 (+84.29%)
Mutual labels:  srt, subtitles, subtitle
pysub-parser
Library for extracting text and timestamps from multiple subtitle files (.ass, .ssa, .srt, .sub, .txt).
Stars: ✭ 40 (-80.95%)
Mutual labels:  subtitles, subtitle, srt
Youtube Transcript Api
This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!
Stars: ✭ 495 (+135.71%)
Mutual labels:  subtitles, subtitle
Go Astisub
Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)
Stars: ✭ 305 (+45.24%)
Mutual labels:  srt, subtitle
Subplayer
📝 SubPlayer is a online subtitle editor
Stars: ✭ 517 (+146.19%)
Mutual labels:  srt, subtitle
Fasubrip
FaSubrip autodetects and converts encoding of farsi (persian) subrip files. with additional functionalities.
Stars: ✭ 22 (-89.52%)
Mutual labels:  srt, subtitle
VTT-to-SRT-Converter
Convert WebVTT subtitles to SubRip.
Stars: ✭ 29 (-86.19%)
Mutual labels:  subtitle, srt
Subfinder
字幕查找器
Stars: ✭ 545 (+159.52%)
Mutual labels:  subtitles, subtitle
Penguin Subtitle Player
An open-source, cross-platform standalone subtitle player
Stars: ✭ 194 (-7.62%)
Mutual labels:  srt, subtitle
chromecast-api
📺 Chromecast Node.js module
Stars: ✭ 122 (-41.9%)
Mutual labels:  subtitles, subtitle
Subed
Subtitle editor for Emacs
Stars: ✭ 77 (-63.33%)
Mutual labels:  srt, subtitles
nekocap
Browser extension for creating & uploading community captions for YouTube, niconico and other video sharing sites.
Stars: ✭ 27 (-87.14%)
Mutual labels:  subtitles, subtitle
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-65.71%)
Mutual labels:  srt, subtitles
Subsync
Synchronize your subtitles using machine learning
Stars: ✭ 84 (-60%)
Mutual labels:  subtitles, subtitle
Translate Subtitle File
🤖 字幕组机翻小助手 - 【功能1:翻译字幕文件】 .srt .ass .vtt 【功能2:语音转文字】(拖入视频或音频识别出字幕) (最新版 v4.1.0 更新时间2021年2月23号) 可配置12家翻译服务商,如谷歌,百度,腾讯,彩云,IBM,Azure,Amazon等(可配置6家语音服务商:阿里云,讯飞,腾讯云,IBM,Azure,Amazon )优点:1. 可以用多家服务商,2. 自己配 API Key 用自己账户的免费额度,比如腾讯每月有500万字符的免费翻译额度,IBM 500分钟的语音转文字免费额度(tern.best 那个域名过期了我不想续费了)
Stars: ✭ 579 (+175.71%)
Mutual labels:  srt, subtitle
Submerger
SRT Subtitles Merger
Stars: ✭ 92 (-56.19%)
Mutual labels:  srt, subtitles
quickSRT
generating .srt(subtitles) in After Effects
Stars: ✭ 24 (-88.57%)
Mutual labels:  subtitle, srt
ccaptioner
An extension to assign a text track to a video element in a web page
Stars: ✭ 45 (-78.57%)
Mutual labels:  subtitles, srt

|travis| |lgtm| |coveralls| |libraries|

.. |travis| image:: https://img.shields.io/travis/cdown/srt/develop.svg?label=tests :target: https://travis-ci.org/cdown/srt :alt: Tests

.. |lgtm| image:: https://img.shields.io/lgtm/grade/python/github/cdown/srt.svg?label=code%20quality :target: https://lgtm.com/projects/g/cdown/srt/overview/ :alt: LGTM

.. |coveralls| image:: https://img.shields.io/coveralls/cdown/srt/develop.svg?label=test%20coverage :target: https://coveralls.io/github/cdown/srt?branch=develop :alt: Coverage

.. |libraries| image:: https://img.shields.io/librariesio/github/cdown/srt.svg?label=dependencies :target: https://libraries.io/github/cdown/srt :alt: Dependencies

srt is a tiny but featureful Python library for parsing, modifying, and composing SRT files. Take a look at the quickstart for a basic overview of the library. Detailed API documentation_ is also available.

Want to see some examples of its use? Take a look at the tools shipped with the library. This library is also used internally by projects like subsync, bw_plex_, and many more.

.. _subsync: https://github.com/smacke/subsync .. _bw_plex: https://github.com/Hellowlol/bw_plex

Why choose this library?

  • Can parse many broken SRT files which other SRT libraries cannot, and fix them
  • Extremely lightweight, ~150 lines of code_ excluding docstrings
  • Simple, intuitive API
  • High quality test suite using Hypothesis_
  • 100% test coverage_ (including branches)
  • Well documented API_, at both a high and low level
  • ~30% faster than pysrt on typical workloads_
  • Full support for PyPy_
  • No dependencies outside of the standard library
  • Tolerant of many common errors found in real-world SRT files
  • Support for Asian-style SRT formats (ie. "fullwidth" SRT format)
  • Completely Unicode compliant
  • Released under a highly permissive license (MIT)
  • Real world tested — used in production to process thousands of SRT files every day
  • Portable — runs on Linux, OSX, and Windows
  • Tools included — contains lightweight tools to perform generic tasks with the library

.. _quickstart: http://srt.readthedocs.org/en/latest/quickstart.html .. _SRT files: https://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format .. _Hypothesis: https://github.com/DRMacIver/hypothesis .. _100% test coverage: https://coveralls.io/github/cdown/srt?branch=develop .. _Well documented API: http://srt.readthedocs.org/en/latest/index.html .. _~150 lines of code: https://paste.pound-python.org/raw/3WgFQIvkVVvBZvQI3nm4/ .. _PyPy: http://pypy.org/ .. _~30% faster than pysrt on typical workloads: https://paste.pound-python.org/raw/8nQKbDW0ROWvS7bOeAb3/

Usage

Tools

There are a number of tools shipped with the library_ to manipulate, process, and fix SRT files. Here's an example using hanzidentifier_ to strip out non-Chinese lines:

.. code::

$ cat pe.srt
1
00:00:33,843 --> 00:00:38,097
Only 3% of the water on our planet is fresh.
地球上只有3%的水是淡水

2
00:00:40,641 --> 00:00:44,687
Yet, these precious waters are rich with surprise.
可是这些珍贵的淡水中却充满了惊奇

$ srt lines-matching -m hanzidentifier -f hanzidentifier.has_chinese -i pe.srt
1
00:00:33,843 --> 00:00:38,097
地球上只有3%的水是淡水

2
00:00:40,641 --> 00:00:44,687
可是这些珍贵的淡水中却充满了惊奇

These tools are easy to chain together, for example, say you have one subtitle with Chinese and English, and other with French, but you want Chinese and French only. Oh, and the Chinese one is 5 seconds later than it should be. That's easy enough to sort out:

.. code::

$ srt lines-matching -m hanzidentifier -f hanzidentifier.has_chinese -i chs+eng.srt |

srt fixed-timeshift --seconds -5 |
srt mux --input - --input fra.srt

See the srt_tools/ directory for more information.

.. _hanzidentifier: https://github.com/tsroten/hanzidentifier

Library

Detailed API documentation_ is available, but here are the basics:

.. code:: python

>>> # list() is needed as srt.parse creates a generator
>>> subs = list(srt.parse('''\
... 1
... 00:00:33,843 --> 00:00:38,097
... 地球上只有3%的水是淡水
...
... 2
... 00:00:40,641 --> 00:00:44,687
... 可是这些珍贵的淡水中却充满了惊奇
...
... 3
... 00:00:57,908 --> 00:01:03,414
... 所有陆地生命归根结底都依赖於淡水
...
... '''))
>>> subs
[Subtitle(index=1, start=datetime.timedelta(0, 33, 843000), end=datetime.timedelta(0, 38, 97000), content='地球上只有3%的水是淡水', proprietary=''),
 Subtitle(index=2, start=datetime.timedelta(0, 40, 641000), end=datetime.timedelta(0, 44, 687000), content='可是这些珍贵的淡水中却充满了惊奇', proprietary=''),
 Subtitle(index=3, start=datetime.timedelta(0, 57, 908000), end=datetime.timedelta(0, 63, 414000), content='所有陆地生命归根结底都依赖於淡水', proprietary='')]
>>> print(srt.compose(subs))
1
00:00:33,843 --> 00:00:38,097
地球上只有3%的水是淡水

2
00:00:40,641 --> 00:00:44,687
可是这些珍贵的淡水中却充满了惊奇

3
00:00:57,908 --> 00:01:03,414
所有陆地生命归根结底都依赖於淡水

Installation

To install the latest stable version from PyPi:

.. code::

pip install -U srt

To install the latest development version directly from GitHub:

.. code::

pip install -U git+https://github.com/cdown/[email protected]

Testing

.. code::

tox

.. _Tox: https://tox.readthedocs.org .. _Detailed API documentation: http://srt.readthedocs.org/en/latest/api.html .. _tools shipped with the library: https://github.com/cdown/srt/tree/develop/srt_tools

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].