Spaces:
Running
Running
Update roop/globals.py
Browse files- roop/globals.py +15 -13
roop/globals.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1 |
-
# globals.py
|
2 |
-
|
3 |
-
# Module-level variables
|
4 |
source_path = None
|
5 |
target_path = None
|
6 |
output_path = None
|
7 |
frame_processors = []
|
8 |
keep_fps = True
|
9 |
keep_audio = True
|
10 |
-
video_encoder = 'libx264'
|
11 |
-
video_quality =
|
12 |
-
log_level = 'error'
|
13 |
|
14 |
def set_global_paths(src: str, tgt: str, out: str) -> None:
|
15 |
"""
|
16 |
Set global paths for source, target, and output.
|
17 |
-
|
18 |
Args:
|
19 |
src (str): Source path.
|
20 |
tgt (str): Target path.
|
@@ -28,7 +24,6 @@ def set_global_paths(src: str, tgt: str, out: str) -> None:
|
|
28 |
def set_processing_options(encoder: str, quality: int, log: str) -> None:
|
29 |
"""
|
30 |
Set options for video processing.
|
31 |
-
|
32 |
Args:
|
33 |
encoder (str): Video encoder.
|
34 |
quality (int): Video quality.
|
@@ -42,7 +37,6 @@ def set_processing_options(encoder: str, quality: int, log: str) -> None:
|
|
42 |
def set_frame_processors(processors: list) -> None:
|
43 |
"""
|
44 |
Set the frame processors.
|
45 |
-
|
46 |
Args:
|
47 |
processors (list): List of frame processors.
|
48 |
"""
|
@@ -52,7 +46,6 @@ def set_frame_processors(processors: list) -> None:
|
|
52 |
def set_keep_options(fps: bool, audio: bool) -> None:
|
53 |
"""
|
54 |
Set options to keep FPS and audio.
|
55 |
-
|
56 |
Args:
|
57 |
fps (bool): Whether to keep FPS.
|
58 |
audio (bool): Whether to keep audio.
|
@@ -61,14 +54,23 @@ def set_keep_options(fps: bool, audio: bool) -> None:
|
|
61 |
keep_fps = fps
|
62 |
keep_audio = audio
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
def some_function():
|
66 |
global source_path, target_path, output_path, frame_processors, keep_fps, keep_audio
|
67 |
-
# Function implementation using global variables
|
68 |
print(f"Source Path: {source_path}")
|
69 |
print(f"Target Path: {target_path}")
|
70 |
print(f"Output Path: {output_path}")
|
71 |
print(f"Frame Processors: {frame_processors}")
|
72 |
print(f"Keep FPS: {keep_fps}")
|
73 |
print(f"Keep Audio: {keep_audio}")
|
74 |
-
|
|
|
|
|
|
|
|
|
1 |
source_path = None
|
2 |
target_path = None
|
3 |
output_path = None
|
4 |
frame_processors = []
|
5 |
keep_fps = True
|
6 |
keep_audio = True
|
7 |
+
video_encoder = 'libx264'
|
8 |
+
video_quality = 50
|
9 |
+
log_level = 'error'
|
10 |
|
11 |
def set_global_paths(src: str, tgt: str, out: str) -> None:
|
12 |
"""
|
13 |
Set global paths for source, target, and output.
|
|
|
14 |
Args:
|
15 |
src (str): Source path.
|
16 |
tgt (str): Target path.
|
|
|
24 |
def set_processing_options(encoder: str, quality: int, log: str) -> None:
|
25 |
"""
|
26 |
Set options for video processing.
|
|
|
27 |
Args:
|
28 |
encoder (str): Video encoder.
|
29 |
quality (int): Video quality.
|
|
|
37 |
def set_frame_processors(processors: list) -> None:
|
38 |
"""
|
39 |
Set the frame processors.
|
|
|
40 |
Args:
|
41 |
processors (list): List of frame processors.
|
42 |
"""
|
|
|
46 |
def set_keep_options(fps: bool, audio: bool) -> None:
|
47 |
"""
|
48 |
Set options to keep FPS and audio.
|
|
|
49 |
Args:
|
50 |
fps (bool): Whether to keep FPS.
|
51 |
audio (bool): Whether to keep audio.
|
|
|
54 |
keep_fps = fps
|
55 |
keep_audio = audio
|
56 |
|
57 |
+
def clean_temp(target_path: str) -> None:
|
58 |
+
"""
|
59 |
+
Cleans up temporary files after processing.
|
60 |
+
Args:
|
61 |
+
target_path (str): Path of the target file to be cleaned up.
|
62 |
+
"""
|
63 |
+
if os.path.exists(target_path):
|
64 |
+
os.remove(target_path)
|
65 |
+
print(f"Cleaned up temporary file: {target_path}")
|
66 |
+
else:
|
67 |
+
print(f"No temporary file found at: {target_path}")
|
68 |
+
|
69 |
def some_function():
|
70 |
global source_path, target_path, output_path, frame_processors, keep_fps, keep_audio
|
|
|
71 |
print(f"Source Path: {source_path}")
|
72 |
print(f"Target Path: {target_path}")
|
73 |
print(f"Output Path: {output_path}")
|
74 |
print(f"Frame Processors: {frame_processors}")
|
75 |
print(f"Keep FPS: {keep_fps}")
|
76 |
print(f"Keep Audio: {keep_audio}")
|
|