Giter Club home page Giter Club logo

ttml2srt's Introduction

ttml2srt

Convert TTML subtitles used by Netflix, HBO, CMore and others to SRT format.

Note: ttml2srt is not a full-featured TTML-to-SRT converter and only works on a small subset of TTML documents. Namely, documents that follow the formats seen on the aforementioned streaming services.

Usage

positional arguments:
  ttml-file             TTML subtitle file
  output-file           file to write resulting SRT to

optional arguments:
  -h, --help            show this help message and exit
  -s [ms], --shift [ms]
                        shift
  -f [fps], --fps [fps]
                        frames per second (default: 23.976)
  --t-dur [sec]         target duration
  --s-dur [sec]         source duration

Common use cases

Simple conversion:

./ttml2srt.py subtitle_from_netflix.xml > subtitle.srt

or

./ttml2srt.py subtitle_from_netflix.xml subtitle.srt

Shift everything forward by 2 secs:

./ttml2srt.py -s 2000 subtitle_from_netflix.xml > subtitle.srt

Convert with specific frame rate (only has an effect when input timestamps have frames):

./ttml2srt.py -f 25 subtitle_from_hbo_nordic.xml > subtitle.srt

You'll probably run into a situation where your target is playing at either slower or faster speed compared to a streaming service. You can scale timestamps to fit a source to a target by picking the same frame from both the target and source and comparing the timestamp.

Here's an example cmd for when the first piece of dialogue from a streaming service is starting two seconds behind the target audio and where a frame towards the end has a timestamp of 00:15:39 (939s) in the target and 00:16:23 (983s) in the source:

./ttml2srt.py -s -2000 --t-dur 939 --s-dur 983 subtitle.xml

Run tests:

python3 tests/test01.py

ttml2srt's People

Contributors

yuppity avatar arvvoid avatar ilyakharlamov avatar moisespr123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.