Overview
Theoffset_generation module creates synthetic test cases by applying time offsets to original videos. It supports both positive offsets (prepending black frames and silent audio) and negative offsets (trimming from the start).
Functions
generate_synthetic_dataset
Directory containing original source videos.
Output directory for shifted videos.
Output directory for the metadata CSV.
List of offsets in milliseconds. Positive values prepend black frames, negative values trim from the start.
- Shifted video files in
synthetic_dir/ - Metadata CSV in
metadata_dir/synthetic_metadata.csvwith columns:video_id: Base name of the original videosynthetic_file_path: Full path to the generated shifted videotrue_offset_ms: Applied offset in millisecondsvideo_length_sec: Duration of the original videomotion_level: Estimated motion energy (0-1)audio_energy_level: Estimated audio RMS energy (0-1)
Helper Functions
_get_video_duration
Path to the video file.
_compute_motion_level
max_frames frames.
Path to the video file.
Maximum number of frames to analyze.
_compute_audio_energy
Path to the video file.
_apply_positive_offset
offset_sec seconds of black video and silent audio, then concatenate with the original.
Path to the input video.
Path where the shifted video will be saved.
Duration of black frames to prepend, in seconds.
_apply_negative_offset
trim_sec seconds from the video.
Path to the input video.
Path where the trimmed video will be saved.
Duration to trim from the start, in seconds.
Usage Example
CLI Usage
- Reads from
evaluation/originals/ - Writes shifted videos to
evaluation/synthetic/ - Writes metadata to
evaluation/metadata/synthetic_metadata.csv - Uses default offsets: [-1000, -500, -100, 100, 500, 1000] ms
Configuration
Default Directories
Default Offsets
Supported Video Extensions
Notes
- Video Quality: Output videos use libx264 codec with CRF 23 and ultrafast preset for speed.
- Audio Handling: Automatically detects whether videos contain audio streams and handles accordingly.
- Sensitivity Tags: Motion level and audio energy are computed to enable sensitivity analysis in later evaluation stages.
- Zero Offset: When offset is 0, the video is re-encoded for consistency with other test cases.