Skip to content

Commit

Permalink
Add suppoer for document filters
Browse files Browse the repository at this point in the history
Add document filter class

Started work

More progress

More progress

Making progress

Making progress

Making progress

First full run

Add color override and documentation
  • Loading branch information
palemieux committed Dec 17, 2023
1 parent 3bc783e commit 2a7345f
Show file tree
Hide file tree
Showing 26 changed files with 989 additions and 149 deletions.
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,15 @@ tt convert -i <input .scc file> -o <output .ttml file>

* `--itype`: `TTML` | `SCC` | `STL` | `SRT` (extrapolated from the filename, if omitted)
* `--otype`: `TTML` | `SRT` | `VTT` (extrapolated from the filename, if omitted)
* `--config` and `--config_file`: JSON dictionaries with the following members:
* `"general": JSON object`: General configuration options (see below)
* `"imsc_writer": JSON object`: IMSC Writer configuration options (see below)
* `"stl_reader": JSON object`: STL Reader configuration options (see below)
* `"vtt_writer": JSON object`: WebVTT Writer configuration options (see below)
* `"srt_writer": JSON object`: SRT Writer configuration options (see below)
* `"scc_reader": JSON object`: SCC Reader configuration options (see below)
* `--filter`: specifies by name a filter to be applied to the content
* `--config` and `--config_file`: JSON dictionary where each property specifies
(optional) configuration parameters for readers, writers and filters.

Example:

`tt convert -i <.scc file> -o <.ttml file> --itype SCC --otype TTML --config '{"general": {"progress_bar":false, "log_level":"WARN"}}'`
`tt convert -i <.scc file> -o <.ttml file> --itype SCC --otype TTML --filter lcd --config '{"general": {"progress_bar":false, "log_level":"WARN"}, "lcd": {"bg_color": "blue"}}'`

### General configuration
### General configuration (`"general"`)

#### progress_bar

Expand Down Expand Up @@ -109,7 +105,7 @@ Example: `"document_lang": "es-419"`

Default: `None`

### IMSC Writer configuration
### IMSC Writer configuration (`"imsc_writer"`)

### time_format

Expand All @@ -131,7 +127,7 @@ Example:

`--config '{"general": {"progress_bar":false, "log_level":"WARN"}, "imsc_writer": {"time_format":"clock_time_with_frames", "fps": "25/1"}}'`

### STL Reader configuration
### STL Reader configuration (`"stl_reader"`)

#### disable_fill_line_gap

Expand Down Expand Up @@ -173,7 +169,7 @@ Specifies a maximum number of rows for open subtitles, either the MNR field of t

Default: `23`

### SRT Writer configuration
### SRT Writer configuration (`"srt_writer"`)

#### text_formatting

Expand All @@ -183,7 +179,7 @@ Default: `23`

Default: `true`

### VTT Writer configuration
### VTT Writer configuration (`"vtt_writer"`)

#### line_position

Expand Down Expand Up @@ -220,7 +216,33 @@ text alignment.

Default: `"auto"`

### Library
### LCD filter configuration (`"lcd"`)

#### safe_area

`"safe_area" : <integer between 0 and 30>`

Specifies the safe area (as a percentage of the height and width of the root container)

Default: `10`

#### color

`"color" : <TTML color> | null`

If not `null`, overrides text color

Default: `null`

#### bg_color

`"color" : <TTML color>`

Specifies the background color of text areas

Default: `"black"`

## Library

The overall architecture of the library is as follows:

Expand Down
36 changes: 0 additions & 36 deletions src/main/python/ttconv/filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,36 +0,0 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# Copyright (c) 2020, Sandflow Consulting LLC
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Data model filter"""

from ttconv.isd import ISD


class Filter:
"""Abstract base class for filters"""

def process(self, isd: ISD):
"""Process the specified ISD and returns it."""
raise NotImplementedError
35 changes: 35 additions & 0 deletions src/main/python/ttconv/filters/doc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# Copyright (c) 2023, Sandflow Consulting LLC
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Data model filter"""

import importlib
import pkgutil
import os.path
import sys

for importer, package_name, _ in pkgutil.iter_modules([os.path.dirname(__file__)]):
full_name = f"{__name__}.{package_name}"
importlib.import_module(full_name)
Loading

0 comments on commit 2a7345f

Please sign in to comment.