This directory contains example scripts that demonstrate how to use the modernized VideoAnnotator pipeline system.
Demonstrates the complete video annotation pipeline processing a single video file through all available pipelines.
Usage:
python examples/basic_video_processing.py --video_path /path/to/video.mp4 --output_dir /path/to/outputFeatures:
- Processes video through all pipelines (scene, person, face, audio)
- Saves individual pipeline results as JSON files
- Comprehensive logging and error handling
- Configurable via YAML configuration files
Processes multiple videos in parallel using the complete pipeline system.
Usage:
python examples/batch_processing.py --input_dir /path/to/videos --output_dir /path/to/outputs --max_workers 4Features:
- Parallel processing of multiple videos
- Configurable number of worker threads
- Batch processing reports and statistics
- CSV summary export
- Individual video result tracking
Tests individual pipelines in isolation, useful for debugging and development.
Usage:
# Test scene detection pipeline
python examples/test_individual_pipelines.py --pipeline scene --video_path /path/to/video.mp4
# Test audio processing pipeline
python examples/test_individual_pipelines.py --pipeline audio --audio_path /path/to/audio.wavFeatures:
- Test individual pipelines independently
- Detailed pipeline information and capabilities
- Results summary and statistics
- Optional JSON output saving
Demonstrates how to create and use custom pipeline configurations for different use cases.
Usage:
python examples/custom_pipeline_config.py --video_path /path/to/video.mp4 --config_type researchConfiguration Types:
high_performance: Maximum accuracy, resource-intensivelightweight: Fast processing, minimal resourcesresearch: All features enabled, experimental settings
All examples use YAML configuration files located in the configs/ directory:
configs/default.yaml- Balanced settings for general useconfigs/high_performance.yaml- High-accuracy settingsconfigs/lightweight.yaml- Fast, resource-efficient settings
Most examples support these common arguments:
--config: Path to YAML configuration file (default:configs/default.yaml)--log_level: Logging level (DEBUG, INFO, WARNING, ERROR)--output_dir: Directory to save results--video_path: Path to input video file--audio_path: Path to input audio file (for audio-specific examples)
All examples generate structured JSON output with consistent schemas:
{
"scenes": [
{
"scene_id": "scene_001",
"start_time": 0.0,
"end_time": 5.2,
"scene_type": "indoor",
"confidence": 0.85
}
],
"total_duration": 120.5,
"total_scenes": 15
}{
"tracks": [
{
"track_id": "person_001",
"detections": [...],
"poses": [...],
"duration": 45.2
}
],
"total_tracks": 3,
"total_detections": 1250
}{
"faces": [
{
"face_id": "face_001",
"emotions": [...],
"landmarks": [...],
"gaze": [...]
}
],
"face_tracks": [...],
"total_faces": 8
}{
"duration": 120.5,
"speech_transcription": {
"text": "Hello world...",
"language": "en",
"word_timestamps": [...]
},
"speaker_diarization": {
"num_speakers": 2,
"segments": [...]
}
}Before running the examples, ensure you have:
-
Installed dependencies:
pip install -r requirements.txt # or conda env create -f environment.yml -
Set up OpenFace 3.0 (if using face analysis): Follow the instructions in
INSTALLATION.md -
Downloaded required models: Some pipelines will automatically download models on first use
All examples include comprehensive error handling:
- Missing files: Clear error messages for missing input files
- Pipeline failures: Individual pipeline errors don't stop the entire process
- Resource constraints: Graceful handling of memory/compute limitations
- Model loading: Fallback options when models are unavailable
- Large videos may require chunked processing
- Batch processing limits concurrent videos
- Pipeline-specific memory optimizations
- Use
--max_workersfor parallel processing - Choose appropriate model sizes in configurations
- Consider frame skipping for faster processing
- Results are saved as JSON (human-readable but larger)
- Consider compression for large batch processing
- Individual pipeline results can be disabled if not needed
To create your own custom example:
-
Import the required pipelines:
from src.pipelines.scene_detection import ScenePipeline, ScenePipelineConfig
-
Create configuration:
config = ScenePipelineConfig( threshold=0.3, min_scene_length=2.0 )
-
Initialize and run pipeline:
pipeline = ScenePipeline(config) results = pipeline.process_video(video_path)
-
Handle results:
with open('results.json', 'w') as f: json.dump(results, f, indent=2, default=str)
- Import errors: Ensure all dependencies are installed
- Model download failures: Check internet connection and disk space
- CUDA/GPU issues: Verify GPU drivers and CUDA installation
- Memory errors: Reduce batch sizes or use lightweight configurations
Enable debug logging for detailed information:
python examples/basic_video_processing.py --log_level DEBUG --video_path video.mp4For performance analysis, consider adding timing information:
import time
start_time = time.time()
results = pipeline.process_video(video_path)
processing_time = time.time() - start_timeTo contribute new examples:
- Follow the existing code structure and naming conventions
- Include comprehensive error handling and logging
- Add configuration options for flexibility
- Document usage and output formats
- Test with various input types and edge cases