-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_playback.py
More file actions
56 lines (40 loc) · 1.6 KB
/
batch_playback.py
File metadata and controls
56 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""Batch process multiple video files."""
import sys
from pathlib import Path
from videoapi.main import VideoAPIApp
def process_video_directory(recordings_dir: str, config_path: str = None):
"""Process all videos in a directory."""
recordings_path = Path(recordings_dir)
if not recordings_path.exists():
print(f"Directory not found: {recordings_dir}")
return
# Find all video files
video_extensions = [".mp4", ".avi", ".mov", ".mkv"]
video_files = []
for ext in video_extensions:
video_files.extend(recordings_path.rglob(f"*{ext}"))
print(f"Found {len(video_files)} video files")
for video_file in video_files:
print(f"\nProcessing: {video_file}")
try:
# Create app instance
app = VideoAPIApp(config_path)
app.setup_playback_mode(str(video_file), loop=False)
# For batch processing, disable visualization
app.config.set("visualization.show_stream", False)
if app.start():
app.run() # This will process the entire video
except KeyboardInterrupt:
print("Interrupted by user")
break
except Exception as e:
print(f"Error processing {video_file}: {e}")
continue
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python batch_playback.py <recordings_directory> [config_file]")
sys.exit(1)
recordings_dir = sys.argv[1]
config_file = sys.argv[2] if len(sys.argv) > 2 else None
process_video_directory(recordings_dir, config_file)