Repository navigation
Expand file tree
/
Copy pathwatch_progress.py
More file actions
140 lines (114 loc) · 4.33 KB
/
Copy pathwatch_progress.py
File metadata and controls
140 lines (114 loc) · 4.33 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python3
"""
Watch progress of movie cleaning in real-time
"""
import time
import subprocess
import sys
from pathlib import Path
import os
def get_video_duration(video_path):
"""Get video duration"""
try:
cmd = ['ffprobe', '-v', 'error', '-show_entries', 'format=duration',
'-of', 'default=noprint_wrappers=1:nokey=1', str(video_path)]
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
return float(result.stdout.strip())
except:
return 0
def format_time(seconds):
"""Format seconds"""
if seconds == 0:
return "N/A"
mins = int(seconds // 60)
secs = int(seconds % 60)
return f"{mins:02d}:{secs:02d}"
def check_process_status():
"""Check what processes are running"""
result = subprocess.run(['ps', 'aux'], capture_output=True, text=True)
lines = result.stdout.split('\n')
code3_running = False
argo_running = False
for line in lines:
if 'clean.py' in line and 'Code_3' in line:
code3_running = True
parts = line.split()
if len(parts) > 2:
cpu = parts[2]
mem = parts[3]
print(f" Code_3: Running (CPU: {cpu}%, MEM: {mem}%)")
if 'clean.py' in line and 'argo' in line:
argo_running = True
parts = line.split()
if len(parts) > 2:
cpu = parts[2]
mem = parts[3]
print(f" argo: Running (CPU: {cpu}%, MEM: {mem}%)")
return code3_running, argo_running
def main():
base_dir = Path("/home/adeel/Link to html/wp_local/movie_cleaner")
cleaned_dir = base_dir / "movies" / "cleaned"
print("=" * 70)
print("MOVIE CLEANING PROGRESS MONITOR")
print("=" * 70)
print()
# Check output files
code3_output = cleaned_dir / "Code_3_cleaned.mkv"
argo_output = cleaned_dir / "argo_cleaned.mp4"
print("=== OUTPUT FILES STATUS ===")
if code3_output.exists():
size = code3_output.stat().st_size / (1024*1024*1024) # GB
print(f" Code_3_cleaned.mkv: EXISTS ({size:.2f} GB)")
# Try to get duration to see if it's complete
duration = get_video_duration(code3_output)
if duration > 0:
print(f" Duration: {format_time(duration)}")
else:
print(f" Code_3_cleaned.mkv: Not created yet")
if argo_output.exists():
size = argo_output.stat().st_size / (1024*1024*1024) # GB
print(f" argo_cleaned.mp4: EXISTS ({size:.2f} GB)")
duration = get_video_duration(argo_output)
if duration > 0:
print(f" Duration: {format_time(duration)}")
else:
print(f" argo_cleaned.mp4: Not created yet")
print()
print("=== PROCESS STATUS ===")
code3_running, argo_running = check_process_status()
if not code3_running and not argo_running:
print(" No processes running - may have completed or not started")
print()
print("=== ESTIMATED PROGRESS ===")
# Check original file sizes
code3_original = base_dir / "movies" / "Code_3.mkv"
argo_original = base_dir / "movies" / "argo" / "argo.mp4"
if code3_original.exists():
orig_size = code3_original.stat().st_size
if code3_output.exists():
out_size = code3_output.stat().st_size
if out_size > 0:
progress = min(100, (out_size / orig_size) * 100)
print(f" Code_3: ~{progress:.1f}% (based on file size)")
else:
print(f" Code_3: Initializing...")
else:
print(f" Code_3: Not started yet")
if argo_original.exists():
orig_size = argo_original.stat().st_size
if argo_output.exists():
out_size = argo_output.stat().st_size
if out_size > 0:
progress = min(100, (out_size / orig_size) * 100)
print(f" argo: ~{progress:.1f}% (based on file size)")
else:
print(f" argo: Initializing...")
else:
print(f" argo: Waiting for Code_3 to complete")
print()
print("=" * 70)
print("Note: Large movies (1-2GB) can take 30-60+ minutes each")
print("Check again in a few minutes for updated progress")
print("=" * 70)
if __name__ == '__main__':
main()