Subtitle group
Pgs
dataclass
¶
An instance of PGS represent a mapping of a PGS file to Python. The PGS.items property contains all PgsSubtitleItem contained within the specified PGS file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tmp_location
|
str
|
Location of a prior extract .sub PGS file. |
required |
temp_folder
|
str
|
Only necessary for debugging. Directory where to dump the metadata. Defaults to "tmp" |
'tmp'
|
items
property
¶
Return PgsSubtitleItems which hold metadata on the image as a PgsImage converted from raw bytes.
Returns:
| Type | Description |
|---|---|
list
|
List containing PgsSubtitleItems which will eventual contain the text extracted from the PGS image. |
__decode(data)
¶
Decodes the PGS file provided as raw bytes and group the contained DisplaySets into unique PgsSubtitleItems.
Returns:
| Type | Description |
|---|---|
list
|
List containing PgsSubtitleItems which will eventual contain the text extracted from the PGS image. |
dump_display_sets(display_sets, path='')
¶
Dumps DisplaySets contained in PGS file as .txt and .json
SubtitleGroup
dataclass
¶
Defines an instance of a SubtitleGroup. A SubtitleGroup wraps around N DisplaySets usually defining a START segment with the following segments defining more objects to display until an END segment.
Within a group subtitles can overlap as PGS supports two windows displaying one image each at a time. The current image is displayed until the window is updated with another image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
list[DisplaySet]
|
List of DisplaySets the SubtitleGroup wraps around. |
required |
__find_global_palettes(members)
¶
Grab all Palette defined at either EPOCH_START, ACQUISITION_POINT or intermediate with varying IDs.
Returns:
| Type | Description |
|---|---|
list
|
Contains all Palettes found in the global Palette definition at ACQUISITION_POINT or intermediate with varying IDs. |
__find_overlap(members)
¶
Check if the current set of DisplaySets between a EPOCH_START, ACQUISITION_POINT & EndSegment have overlapping Windows. In PGS there can be at most two overlapping Windows at a time.
Returns:
| Type | Description |
|---|---|
bool
|
Returns TRUE right away if there is any overlap found. |
__find_overlapping(reset_positions, redef_positions, members)
¶
Finds the actual DisplaySets which are overlapping starting from each REDEF segment position until the immediately following RESET segment is reached.
Returns:
| Type | Description |
|---|---|
dict
|
Contains all DisplaySets that are overlapping grouped by the REDEF segments position. |
__find_redefinition_positions(members, reset_pos)
¶
In PGS REDEF segments usually define a new set of Palettes, Windows and CompositionObjects. They also define the number of Windows currently active. REDEF segments usually follow RESET segments as they define new content and their positions about to come after.
This finds these positions.
A START segment is also a valid REDEF segment.
Returns:
| Type | Description |
|---|---|
list
|
Contains indices of REDEF segments. |
__find_reset_positions(members)
¶
In PGS files END segments are usually sized to 11 bytes, contain no objects & are placed at the end of the group. However, if elements overlap an additional intermediate RESET segment is inserted which drops the number of objects and marks the position a Palette update can happen & either new elements can overlap or the overlap ends.
PGS subtitles can only show 2 objects on screen at once.
This finds these positions.
They seem to always be marked with a size of 19 bytes and dropping the number of segments, which will always be 1.
Returns:
| Type | Description |
|---|---|
list
|
Contains the indices of the RESET segments. |
__gen_pgs_subtitle_items(timelines)
¶
Generate PgsSubtitleItems which hold metadata on the image as a PgsImage converted from raw bytes and the matching Palette defined.
Returns:
| Type | Description |
|---|---|
list
|
List containing PgsSubtitleItems which will eventual contain the text extracted from the PGS image. |