Supported formats
==================
Read: - DFXP/TTML - SAMI - SCC - SRT - WebVTT
Write: - DFXP/TTML - SAMI - SRT - Transcript - WebVTT
See the `examples
folder `__ for
example captions that currently can be read correctly.
SAMI Reader / Writer :: `spec `__
----------------------------------------------------------------------------------------
Microsoft Synchronized Accessible Media Interchange. Supports multiple
languages.
Supported Styling: - text-align - italics - font-size - font-family -
color
If the SAMI file is not valid XML (e.g. unclosed tags), will still
attempt to read it.
DFXP/TTML Reader / Writer :: `spec `__
-------------------------------------------------------------------
The W3 standard. Supports multiple languages.
Supported Styling: - text-align - italics - font-size - font-family -
color
SRT Reader / Writer :: `spec `__
----------------------------------------------------------------------------------------
SubRip captions. If given multiple languages to write, will output all
joined together by a 'MULTI-LANGUAGE SRT' line.
Supported Styling: - None
Assumes input language is english. To change:
::
pycaps = SRTReader().read(srt_content, lang='fr')
WebVTT Reader / Writer :: `spec `__
-----------------------------------------------------------------
**WebVTT** is a W3C standard for displaying timed text in HTML5. Its
specification is currently (as of February 2015) in draft stage and
therefore not all features are implemented by major players, the same
being true for ``pycaption``.
By default, the reader assumes the language is English and the writer
returns the first language it finds in the caption set. You can specify
a language using the ``lang`` parameter:
::
pycaps = WebVTTReader().read(content, lang='fr')
If you need to adjust all timestamps in a WebVTT, you can use the
``time_shift_milliseconds`` parameter which moves the timestamps
forward (positive integer) or backward (negative integer) with
the specified amount:
::
pycaps = WebVTTReader(time_shift_milliseconds=1154).read(content)
Styling
^^^^^^^
Styling in WebVTT can be done via inline tags (e.g. ````, ```` etc.) or external
CSS rules applied to text wrapped in class (````) or voice (````) tags.
``pycaption`` currently only keeps *voice tags* on conversion.
Example:
::
Hi, my name is Fred
is converted to
::
Fred: Hi, my name is Fred
The following WebVTT supported tags are stripped off the cue text:
- ````, ````, ````, ````, ````, ``