Overview
Therun_batch module executes both audio-based (GCC-PHAT) and visual-based (motion correlation) synchronization on all synthetic test cases, recording accuracy, confidence, runtime, and resource usage metrics.
Functions
run_batch
Path to the synthetic metadata CSV generated by
offset_generation.Directory containing original source videos.
Output directory for the results CSV.
Output directory for motion signal diagnostics (NPZ files for visualization).
-
results_dir/results.csvwith columns:video_id: Video identifiertrue_offset_ms: Ground truth offsetmethod_type: “audio” or “visual”estimated_offset_ms: Estimated offset by the methodabsolute_error_ms: |estimated - true|confidence_score: Confidence metric (0-1)runtime_seconds: Execution timepeak_cpu_percent: Peak CPU usage during syncpeak_memory_mb: Peak memory usage during syncvideo_length_sec: Video durationmotion_level: Motion energy levelaudio_energy_level: Audio RMS energy level
-
diagnostics_dir/*.npz: Motion signals for before/after visualization
Helper Functions
_run_audio_sync
Path to the original video.
Path to the synthetic (shifted) video.
estimated_offset_ms: Estimated offset in millisecondsconfidence_score: GCC-PHAT peak confidenceruntime_seconds: Execution timepeak_cpu_percent: Peak CPU usagepeak_memory_mb: Peak memory usage
_run_visual_sync
Path to the original video.
Path to the synthetic (shifted) video.
If provided, saves motion signals as NPZ files for later visualization.
Label for the diagnostic NPZ file (e.g., “video1_offset+500”).
estimated_offset_ms: Estimated offset in millisecondsconfidence_score: Motion correlation peak confidenceruntime_seconds: Execution timepeak_cpu_percent: Peak CPU usagepeak_memory_mb: Peak memory usage
ResourceMonitor
Sampling interval in seconds.
peak_cpu_percent: Maximum CPU percentage observedpeak_memory_mb: Maximum memory usage in MB observed
_read_metadata
Path to the metadata CSV file.
_find_original_video
video_id in originals_dir.
Video identifier (filename without extension).
Directory to search for the original video.
_has_audio_stream
Path to the video file.
Usage Example
CLI Usage
evaluation/results/results.csv.
Configuration
Default Paths
Result CSV Fields
Notes
- Method Types: Each test case is evaluated with both
"audio"and"visual"methods. - Sign Convention: Estimated offsets follow the same sign convention as true offsets (positive = prepend, negative = trim).
- Temporary Directories: Uses
tempfile.mkdtemp()for isolated working directories per test case. - Error Handling: Logs failures for individual test cases but continues processing remaining cases.
- Progress Logging: Outputs detailed progress including estimated offset, error, confidence, runtime, and resource usage for each test case.