Defines standardized interfaces and data structures for media analysis (VAD, Scene Detection) and processing (FFmpeg, Conversion) plugins within the cjm-plugin-system ecosystem.
Project description
cjm-media-plugin-system
Install
pip install cjm_media_plugin_system
Project Structure
nbs/
├── analysis_interface.ipynb # Domain-specific plugin interface for media analysis (read-only / signal extraction)
├── core.ipynb # DTOs for media analysis and processing with FileBackedDTO support for zero-copy transfer
└── processing_interface.ipynb # Domain-specific plugin interface for media processing (write / file manipulation)
Total: 3 notebooks
Module Dependencies
graph LR
analysis_interface[analysis_interface<br/>Media Analysis Plugin Interface]
core[core<br/>Core Data Structures]
processing_interface[processing_interface<br/>Media Processing Plugin Interface]
analysis_interface --> core
processing_interface --> core
2 cross-module dependencies detected
CLI Reference
No CLI commands found in this project.
Module Overview
Detailed documentation for each module in the project:
Media Analysis Plugin Interface (analysis_interface.ipynb)
Domain-specific plugin interface for media analysis (read-only / signal extraction)
Import
from cjm_media_plugin_system.analysis_interface import (
MediaAnalysisPlugin
)
Classes
class MediaAnalysisPlugin(PluginInterface):
"""
Abstract base class for plugins that analyze media files.
Analysis plugins perform read-only operations that extract temporal segments
from media files (VAD, scene detection, beat detection, etc.).
"""
def execute(
self,
media_path: Union[str, Path], # Path to media file to analyze
**kwargs
) -> MediaAnalysisResult: # Analysis result with detected TimeRanges
"Analyze the media file and return detected temporal segments."
Core Data Structures (core.ipynb)
DTOs for media analysis and processing with FileBackedDTO support for zero-copy transfer
Import
from cjm_media_plugin_system.core import (
TimeRange,
MediaMetadata,
MediaAnalysisResult
)
Classes
@dataclass
class TimeRange:
"Represents a temporal segment within a media file."
start: float # Start time in seconds
end: float # End time in seconds
label: str = 'segment' # Segment type (e.g., 'speech', 'silence', 'scene')
confidence: Optional[float] # Detection confidence (0.0 to 1.0)
payload: Dict[str, Any] = field(...) # Extra data (e.g., speaker embedding)
def to_dict(self) -> Dict[str, Any]: # Serialized representation
"Convert to dictionary for JSON serialization."
@dataclass
class MediaMetadata:
"Container for media file metadata."
path: str # File path
duration: float # Duration in seconds
format: str # Container format (e.g., 'mp4', 'mkv')
size_bytes: int # File size in bytes
video_streams: List[Dict[str, Any]] = field(...) # Video stream info
audio_streams: List[Dict[str, Any]] = field(...) # Audio stream info
def to_dict(self) -> Dict[str, Any]: # Serialized representation
"Convert to dictionary for JSON serialization."
@dataclass
class MediaAnalysisResult:
"Standard output for media analysis plugins."
ranges: List[TimeRange] # Detected temporal segments
metadata: Dict[str, Any] = field(...) # Global analysis stats
def to_temp_file(self) -> str: # Absolute path to temporary JSON file
"""Save results to a temp JSON file for zero-copy transfer."""
tmp = tempfile.NamedTemporaryFile(suffix=".json", delete=False, mode='w')
data = {
"ranges": [r.to_dict() for r in self.ranges],
"Save results to a temp JSON file for zero-copy transfer."
def from_file(
cls,
filepath: str # Path to JSON file
) -> "MediaAnalysisResult": # Loaded result instance
"Load results from a JSON file."
Media Processing Plugin Interface (processing_interface.ipynb)
Domain-specific plugin interface for media processing (write / file manipulation)
Import
from cjm_media_plugin_system.processing_interface import (
MediaProcessingPlugin
)
Classes
class MediaProcessingPlugin(PluginInterface):
"""
Abstract base class for plugins that modify, convert, or extract media.
Processing plugins perform write operations that produce new files
(format conversion, segment extraction, re-encoding, etc.).
"""
def execute(
self,
action: str = "get_info", # Operation: 'get_info', 'convert', 'extract_segment'
**kwargs
) -> Dict[str, Any]: # JSON-serializable result (usually containing 'output_path')
"Execute a media processing operation."
def get_info(
self,
file_path: Union[str, Path] # Path to media file
) -> MediaMetadata: # File metadata (duration, codec, streams)
"Get metadata for a media file."
def convert(
self,
input_path: Union[str, Path], # Source file path
output_format: str, # Target format (e.g., 'mp4', 'wav')
**kwargs
) -> str: # Path to converted file
"Convert media to a different format."
def extract_segment(
self,
input_path: Union[str, Path], # Source file path
start: float, # Start time in seconds
end: float, # End time in seconds
output_path: Optional[str] = None # Custom output path (auto-generated if None)
) -> str: # Path to extracted segment file
"Extract a temporal segment from a media file."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cjm_media_plugin_system-0.0.1.tar.gz.
File metadata
- Download URL: cjm_media_plugin_system-0.0.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceef891c15ca86cb05fe903f9e37fe1fc5bd5c8552a966f489bcd2ca308c9d73
|
|
| MD5 |
17627b4a93b01e115d5cab2de40537c3
|
|
| BLAKE2b-256 |
52e04af51429a21ab2c6947a7f20fa715a5d773289a0a41e74a0cfee6c5bc128
|
File details
Details for the file cjm_media_plugin_system-0.0.1-py3-none-any.whl.
File metadata
- Download URL: cjm_media_plugin_system-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06e4fb42ca12dc58113582913b4dea70b3fa4e9fd47af897c135bd48836dd9ba
|
|
| MD5 |
20bec0e4abd1f6a61b38037f8cb3e545
|
|
| BLAKE2b-256 |
babc3d34d9176a4b91a78ea6fd28e2939f767033316ffb86e275a8428957858c
|