pycaption Documentation Release 0.5.0

PBS

Jun 16, 2021

Contents

1 Table of contents 3 1.1 Introduction...... 3 1.1.1 Python Usage...... 4 1.2 Supported formats...... 5 1.2.1 SAMI Reader / Writer :: spec...... 5 1.2.2 DFXP/TTML Reader / Writer :: spec...... 5 1.2.3 SRT Reader / Writer :: spec...... 6 1.2.4 WebVTT Reader / Writer :: spec...... 6 1.2.5 SCC Reader :: spec...... 7 1.2.6 Transcript Writer...... 7 1.3 Extensibility...... 7

i ii pycaption Documentation, Release 0.5.0 pycaption is a python library for converting caption formats.

Contents 1 pycaption Documentation, Release 0.5.0

2 Contents CHAPTER 1

Table of contents

1.1 Introduction pycaption is a caption reading/writing module. Use one of the given Readers to read content into a CaptionSet object, and then use one of the Writers to output the CaptionSet into captions of your desired format. Requires Python 2.7. Turn a caption into multiple caption outputs: srt_caps=u'''1 00:00:09,209 --> 00:00:12,312 This is an example SRT file, which, while extremely short, is still a valid SRT file. ''' converter= CaptionConverter() converter.read(srt_caps, SRTReader()) print converter.write(SAMIWriter()) print converter.write(DFXPWriter()) print converter.write(pycaption.transcript.TranscriptWriter())

Not sure what format the caption is in? Detect it: from pycaption import detect_format caps=u'''1 00:00:01,500 --> 00:00:12,345 Small caption''' reader= detect_format(caps) if reader: print SAMIWriter().write(reader().read(caps))

3 pycaption Documentation, Release 0.5.0

Or if you expect to have only a subset of the supported input formats: caps=u'''1 00:00:01,500 --> 00:00:12,345 Small caption''' if SRTReader().detect(caps): print SAMIWriter().write(SRTReader().read(caps)) elif DFXPReader().detect(caps): print SAMIWriter().write(DFXPReader().read(caps)) elif SCCReader().detect(caps): print SAMIWriter().write(SCCReader().read(caps))

1.1.1 Python Usage

Example: Convert from SAMI to DFXP from pycaption import SAMIReader, DFXPWriter sami=u'''NOVA3213

( clock ticking )

FRENCH LINE 1!

 

MAN:
When we think
of E equals m c-squared,

FRENCH LINE 2?

''' print DFXPWriter().write(SAMIReader().read(sami))

Which will output the following:

(continues on next page)

4 Chapter 1. Table of contents pycaption Documentation, Release 0.5.0

(continued from previous page)