Overview
Video clip processor family.
This package provides processors for extracting video clips from longer videos based on time ranges or keyframe boundaries.
Exported Classes
VideoClipProcessor-- Abstract base for video clip extraction.GstVideoClipProcessor-- GStreamer-based video clip processor.GstVideoClipConfig-- GStreamer video clip configuration.GstVideoClipProcessConfig-- GStreamer video clip process configuration.
GstVideoClipConfig
Bases: GstBaseConfig
Stable configuration for GstVideoClipProcessor.
Set once at construction. Controls encoder selection, timeout, and other processor behaviour that does not change per attachment.
Attributes:
| Name | Type | Description |
|---|---|---|
default_windows |
list[tuple[float, float]] | None
|
Default clipping
windows used when |
validate_default_windows(default_windows)
classmethod
Validate the constructor-level default windows, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_windows
|
list[tuple[float, float]] | None
|
The candidate default windows to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[float, float]] | None
|
list[tuple[float, float]] | None: |
list[tuple[float, float]] | None
|
when |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
GstVideoClipProcessConfig
Bases: ProcessorProcessConfig
Per-invocation configuration for process.
Attributes:
| Name | Type | Description |
|---|---|---|
windows |
list[tuple[float, float]]
|
Ordered |
validate_windows(windows)
classmethod
Validate that every clipping window is non-empty and well ordered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
windows
|
list[tuple[float, float]]
|
The windows to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[float, float]]
|
list[tuple[float, float]]: The validated windows. |
GstVideoClipProcessor(windows=None, config=None)
Bases: BaseGstreamerProcessor, VideoClipProcessor
Clips a video attachment to one or more [start_time, end_time] windows.
Stable settings belong in GstVideoClipConfig (constructor).
Per-call clip windows belong in GstVideoClipProcessConfig
(process(..., process_config=...)).
Initialise the clip processor.
Deprecated
The windows parameter is deprecated. Pass config=GstVideoClipConfig(default_windows=windows) instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
windows
|
list[tuple[float, float]] | None
|
Deprecated.
Default windows applied at construction. Equivalent to passing
|
None
|
config
|
dict[str, Any] | GstVideoClipConfig | None
|
Optional stable
configuration. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
config_model()
classmethod
Return the stable configuration model for this processor.
Returns:
| Type | Description |
|---|---|
type[GstVideoClipConfig]
|
type[GstVideoClipConfig]: The stable configuration model for this processor. |
process_config_model()
classmethod
Return the per-invocation configuration model for this processor.
Returns:
| Type | Description |
|---|---|
type[GstVideoClipProcessConfig]
|
type[GstVideoClipProcessConfig]: The per-invocation configuration model for this processor. |
set_windows(windows)
Update the constructor-level default windows.
Mutates config so process falls back to windows when
no process_config is supplied. Prefer passing
GstVideoClipProcessConfig to process for per-call
overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
windows
|
list[tuple[float, float]]
|
The windows to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
|
None
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
VideoClipProcessor()
Bases: BackendSelectableProcessor[Attachment, Attachment], ABC
Family base for clipping video attachments to time windows.
This class serves as a unified entry point for video clipping operations. It automatically routes requests to the most appropriate, available backend implementation based on your system environment.
Why use this base class?
- Portability: Your code will run regardless of which underlying libraries are installed on the host machine.
- Simplicity: No need to handle fallback logic or conditional imports yourself.
- Future-proofing: New backends can be added to the library without requiring changes to your application code.
Usage Example
from gllm_multimodal.media_toolkit.processor.video_clip_processor import VideoClipProcessor
from gllm_inference.schema import Attachment
# Instantiates the best available backend automatically
processor = VideoClipProcessor.build()
# Set the target clipping window (start_time, end_time) in seconds
processor.set_windows([(10.0, 20.5)])
attachment = Attachment(url="file:///path/to/video.mp4")
clipped_video = processor(attachment)
from gllm_multimodal.media_toolkit.processor.video_clip_processor import VideoClipProcessor
from gllm_inference.schema import Attachment
# Explicitly force the ffmpeg backend
processor = VideoClipProcessor.build(backend="ffmpeg")
processor.set_windows([(10.0, 20.5)])
attachment = Attachment(url="file:///path/to/video.mp4")
clipped_video = processor(attachment)
from gllm_multimodal.media_toolkit.processor.video_clip_processor import VideoClipProcessor
from gllm_inference.schema import Attachment
# Explicitly force the moviepy backend
processor = VideoClipProcessor.build(backend="moviepy")
processor.set_windows([(10.0, 20.5)])
attachment = Attachment(url="file:///path/to/video.mp4")
clipped_video = processor(attachment)
set_windows(windows)
abstractmethod
Configure one or more [start, end] clipping windows for the next call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
windows
|
list[tuple[float, float]]
|
List of (start, end) tuples in seconds. |
required |