Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved EBU-TT-D encoding, including better tests and denester #523

Open
wants to merge 21 commits into
base: release/3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ coverage.xml
*,cover
.hypothesis/

# Pytest cache
.pytest_cache/

# Translations
*.mo
*.pot
Expand Down
3 changes: 3 additions & 0 deletions docs/source/configurator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ Node type dependent options for [nodeN] : ::

type="distributor" : No options

type="denester"
└─sequence_identifier : sequence identifier, default "Denester1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is not (yet) supported by the Denester.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, to be fixed by pushing more commits here - we have this fixed in the BBC fork. Apologies!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, no problem! So I will put my review on hold, until I get news from you regarding this MR.


Output carriage type dependent options for "carriage": ::

type="direct"
Expand Down
37 changes: 37 additions & 0 deletions docs/source/denesting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Denesting of EBU-TT-Live documents
======================================

DenesterNode should be used when a EBU-TT-3 document has a div that contains
other divs, or a span contains another span, and those nested elements need
to be flattened, for example before conversion to EBU-TT-D. These elements
are not able to be nested inside each other in EBU-TT-D documents.

When documents are Denested, any nested elements must be removed from
their parent elements, while retaining attributes they would have inherited.
To address this, the DenesterNode node processes the
document(s) with the
:py:func:`ebu_tt_live.node.denester.DenesterNode.recurse` and
:py:func:`ebu_tt_live.node.denester.DenesterNode.recurse_span`
functions. These will iterate through the file to locate the deepest
nested element, and create a new copy of it with its content and
expected inherited attributes. The end result is a file containing
these newly created divs/spans in place of the nested ones.

Once the new divs and spans are created, divs that are sequential in
the list of divs and have the same attributes are combined into a single
div. This is done by the
:py:func:`ebu_tt_live.node.denester.DenesterNode.combine_divs`
function to reduce the number of divs in the resulting file.

In the combined divs, every p element should have the same region
as its parent div. Any p elements that specify a different region
to their inherited region are removed here: as per TTML semantics,
such p elements are never presented.
The
:py:func:`ebu_tt_live.node.denester.DenesterNode.check_p_regions`
function iterates through the divs that have an assigned region and
removes any p where its region does not match.
It then removes the region attribute from any remaining p, as it will
inhert the region of its parent div and the attribute is unnecessary.
It will also remove any now-empty divs that exist as a result of having
their p elements removed.
8 changes: 8 additions & 0 deletions docs/source/ebu_tt_live.node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ node Package
:members:
:undoc-members:
:show-inheritance:

:mod:`denester` Module
----------------------

.. automodule:: ebu_tt_live.node.denester
:members:
:undoc-members:
:show-inheritance:
5 changes: 5 additions & 0 deletions docs/source/inode.puml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class BufferDelayNode {
+process_document()
}

class DenesterNode{
..methods..
+process_document()
}

class RetimingDelayNode{
..methods..
+process_document()
Expand Down
1 change: 1 addition & 0 deletions docs/source/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ The components mimic the nodes and carriage mechanisms defined in the specificat
timing_resolution
segmentation
deduplication
denesting
conversion
11 changes: 11 additions & 0 deletions docs/source/scripts_and_their_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ attributes are duplicated.
For the default configuration of the node, see:
``ebu-run --admin.conf=ebu_tt_live/examples/config/deduplicator_fs.json``

Denester Node
-------------
This node flattens nested ``div`` and ``span`` elements such that no
``div`` ends up containing a ``div`` and no ``span`` ends up containing
a ``span``. It also removes any ``p`` elements that specify a ``region``
attribute that differs from a specified region on an ancestor element.

If nested ``div`` or ``span`` elements might be present in a document, the
Denester node should be used to flatten them before passing them to the
EBU-TT-D Encoder, because EBU-TT-D does not permit such nested elements.

Retiming Delay Node
-------------------
This script modifies the times within each Document and issues them without
Expand Down
2 changes: 1 addition & 1 deletion ebu_tt_live/adapters/document_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, media_clock=None):
self._converter = EBUTT3EBUTTDConverter(media_clock=media_clock)

def convert_data(self, data, **kwargs):
return EBUTTDDocument.create_from_raw_binding(self._converter.convert_document(data)), kwargs
return EBUTTDDocument.create_from_raw_binding(self._converter.convert_document(data.binding)), kwargs


def get_document_data_adapter(expects, provides):
Expand Down
Loading