Scening Tool API¶
API for extending the Scening tool with custom parsers and serializers.
Core Classes¶
Classes¶
Parser
¶
Bases: ABC
Base class for implementing custom scening parsers.
Parsers are responsible for reading file-like objects and converting them into SceneRow objects,
which contain lists of frames or timestamps.
To implement a parser, create a subclass and:
- Define the
filterclass variable. - Implement the
parsemethod. - Register it using the
vsview_scening_register_parserhook.
Attributes¶
FileFilter
¶
FileFilter: type[_FileFilter] = _FileFilter
Alias to FileFilter for convenience in subclasses.
filter
¶
The file filter used by the plugin to identify supported files in the import dialog.
Functions¶
parse
¶
Parse a binary stream into one or more SceneRow objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
io
|
BinaryIO
|
The input binary stream. |
required |
name
|
str
|
The suggested name for the scene (usually the base filename). |
required |
fps
|
Fraction
|
The frame rate of the current video project, used for frame conversions. |
required |
Returns:
| Type | Description |
|---|---|
SceneRow | Sequence[SceneRow]
|
A single scene or a sequence of scenes. |
Source code in src/vsview/app/tools/scening/api.py
get_color
¶
get_color() -> QColor
Get a suggested color for the new scene row.
This method is monkey-patched onto parser instances by the scening tool during the import process. It uses a golden-ratio-based generator to ensure distinct colors for adjacent scenes.
Returns:
| Type | Description |
|---|---|
QColor
|
A suggested color for the new scene. |
Source code in src/vsview/app/tools/scening/api.py
Serializer
¶
Bases: ABC
Base class for implementing custom scening exporters.
Serializers are responsible for taking a list of ranges and writing them to a file-like object in a specific format.
To implement a serializer, create a subclass and:
- Define the
filterclass variable. - Implement the
serializemethod. - Register it using the
vsview_scening_register_serializerhook.
Attributes¶
FileFilter
¶
FileFilter: type[_FileFilter] = _FileFilter
Alias to FileFilter for convenience in subclasses.
filter
¶
The file filter used by the plugin to identify supported files in the export dialog.
Functions¶
serialize
¶
serialize(io: BinaryIO, ranges: Iterator[UnifiedRange]) -> None
Serialize a set of ranges into a binary stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
io
|
BinaryIO
|
The output binary stream. |
required |
ranges
|
Iterator[UnifiedRange]
|
An iterator of UnifiedRange objects.
These provide helpers like |
required |
Source code in src/vsview/app/tools/scening/api.py
FileFilter
¶
Bases: NamedTuple
Metadata used to define file types in the scening tool's import/export dialogs.
Models¶
Classes¶
RangeFrame
¶
RangeTime
¶
SceneRow
¶
Bases: UUIDModel
Represents a collection of ranges grouped under a single name and color.
UnifiedRange
¶
UnifiedRange(
r: RangeFrame | RangeTime,
frame_to_time: Callable[[int], Time],
time_to_frame: Callable[[timedelta], int],
)
A helper wrapper providing a unified interface for frame and time-based ranges.
Source code in src/vsview/app/tools/scening/models.py
Functions¶
as_frames
¶
Convert the range to a tuple of (start_frame, end_frame).
Source code in src/vsview/app/tools/scening/models.py
as_times
¶
Convert the range to a tuple of (Time, Time).
Source code in src/vsview/app/tools/scening/models.py
Utility & Hook¶
Attributes¶
Functions¶
borrowed_text_wrapper
¶
borrowed_text_wrapper(
stream: BinaryIO, encoding: str = "utf-8", errors: str = "strict"
) -> Iterator[TextIOWrapper]
A context manager that wraps a binary stream into a text stream without closing it.