Export Service
app.application.services.export_serviceVideo export service for rendering blurred videos and detection exports.
See Also
ExportWorkerFactoryAdapter— creates session export workersExportAllWorkerFactoryAdapter— creates batch export workers
Layer: Application. Context: Coordinates domain state and infrastructure to complete application use cases.
ExportProgressCallback = Callable[[int, int], None]
ExportService
Bases: QObject
Orchestrates video export.
Responsibilities
- Render blurred video with bounding boxes from
DataLayer.D. - Export annotations as JSON (structured metadata).
- Export annotations as CSV (spreadsheet format).
- Report progress during multi-frame export.
- Apply blur effects to detected/tracked regions.
Note
Prefers Layer D when populated and falls back to Layer C for unseeded sessions.
Export Formats: Video — MP4 with blur overlay, H.264 codec, original FPS/resolution. JSON — Metadata per frame: frame_index, timestamp, boxes with labels/confidence. CSV — Tab-separated: frame_index, box_id, label, coords, confidence, source.
Designed to run in background thread (ExportWorker) via progress callbacks.
Processes entire video frame-by-frame (can be slow).
Blur strength controlled via session settings.
Exports DataLayer.D (user-edited tracking/detection final results).
Blurs the union of bounding boxes once with a 10-pixel outward feather.
Kernel size is configurable via ProcessingSettings.blur_strength.
Selected box interiors remain fully blurred; editor preview is unchanged.
| PARAMETER | DESCRIPTION |
|---|---|
app
|
Application used to resolve the session, read its frames, and coordinate video export.
TYPE:
|
__init__(app: Application) -> None
export_annotations_csv(s_id: SessionId, output_path: str) -> None
Write the session's stored boxes to a CSV file.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Identifier of the session whose boxes should be exported.
TYPE:
|
output_path
|
Destination path for the CSV file.
TYPE:
|
export_session(s_id: SessionId, output_path: str, progress_callback: ExportProgressCallback | None = None) -> None
Export session to a blurred MP4 video file.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Session ID to export.
TYPE:
|
output_path
|
File path for output video (e.g., "/path/video_exported.mp4").
TYPE:
|
progress_callback
|
Optional callback
TYPE:
|
Example
export_service.export_session(
s_id=session_id,
output_path="/home/user/videos/output.mp4",
progress_callback=lambda cur, total: print(f"{cur}/{total}")
)
Note
Output Files Generated:
{output_path} — Blurred video (MP4).
Flow: export_session(s_id, output_path, progress_callback) └──> Render blurred video with progress callback
session_is_ready_for_export(s_id: SessionId) -> bool
Check if a session has data ready to export.
| PARAMETER | DESCRIPTION |
|---|---|
s_id
|
Session ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
Note
Export favors editable tracking output (Layer D). For sessions where Layer D has not been seeded yet, raw tracking output (Layer C) is accepted as a fallback.