Skip to content

Industry leading face manipulation platform

Introduce Commands type

henryruhs99c514c58f08
diff --git a/facefusion/download.py b/facefusion/download.py
index ac54316b..25662d45 100644
--- a/facefusion/download.py
+++ b/facefusion/download.py
@@ -11,12 +11,11 @@ import facefusion.choices
from facefusion import logger, process_manager, state_manager, wording
from facefusion.filesystem import get_file_name, get_file_size, is_file, remove_file
from facefusion.hash_helper import validate_hash
-from facefusion.typing import DownloadProvider, DownloadSet
+from facefusion.typing import Commands, DownloadProvider, DownloadSet
-def open_curl(args : List[str]) -> subprocess.Popen[bytes]:
- commands = [ shutil.which('curl'), '--silent', '--insecure', '--location' ]
- commands.extend(args)
+def open_curl(commands : Commands) -> subprocess.Popen[bytes]:
+ commands = [ shutil.which('curl'), '--silent', '--insecure', '--location' ] + commands
return subprocess.Popen(commands, stdin = subprocess.PIPE, stdout = subprocess.PIPE)
diff --git a/facefusion/ffmpeg.py b/facefusion/ffmpeg.py
index 381b0272..919db207 100644
--- a/facefusion/ffmpeg.py
+++ b/facefusion/ffmpeg.py
@@ -9,14 +9,13 @@ from tqdm import tqdm
from facefusion import logger, process_manager, state_manager, wording
from facefusion.filesystem import get_file_format, remove_file
from facefusion.temp_helper import get_temp_file_path, get_temp_frames_pattern, resolve_temp_frame_paths
-from facefusion.typing import AudioBuffer, Fps, OutputVideoPreset, UpdateProgress
+from facefusion.typing import AudioBuffer, Commands, Fps, OutputVideoPreset, UpdateProgress
from facefusion.vision import count_trim_frame_total, detect_video_duration, restrict_video_fps
-def run_ffmpeg_with_progress(args: List[str], update_progress : UpdateProgress) -> subprocess.Popen[bytes]:
+def run_ffmpeg_with_progress(commands : Commands, update_progress : UpdateProgress) -> subprocess.Popen[bytes]:
log_level = state_manager.get_item('log_level')
- commands = [ shutil.which('ffmpeg'), '-hide_banner', '-nostats', '-loglevel', 'error', '-progress', '-' ]
- commands.extend(args)
+ commands = [ shutil.which('ffmpeg'), '-hide_banner', '-nostats', '-loglevel', 'error', '-progress', '-' ] + commands
process = subprocess.Popen(commands, stderr = subprocess.PIPE, stdout = subprocess.PIPE)
while process_manager.is_processing():
@@ -39,10 +38,9 @@ def run_ffmpeg_with_progress(args: List[str], update_progress : UpdateProgress)
return process
-def run_ffmpeg(args : List[str]) -> subprocess.Popen[bytes]:
+def run_ffmpeg(commands : Commands) -> subprocess.Popen[bytes]:
log_level = state_manager.get_item('log_level')
- commands = [ shutil.which('ffmpeg'), '-hide_banner', '-nostats', '-loglevel', 'error' ]
- commands.extend(args)
+ commands = [ shutil.which('ffmpeg'), '-hide_banner', '-nostats', '-loglevel', 'error' ] + commands
process = subprocess.Popen(commands, stderr = subprocess.PIPE, stdout = subprocess.PIPE)
while process_manager.is_processing():
@@ -59,9 +57,8 @@ def run_ffmpeg(args : List[str]) -> subprocess.Popen[bytes]:
return process
-def open_ffmpeg(args : List[str]) -> subprocess.Popen[bytes]:
- commands = [ shutil.which('ffmpeg'), '-loglevel', 'quiet' ]
- commands.extend(args)
+def open_ffmpeg(commands : Commands) -> subprocess.Popen[bytes]:
+ commands = [ shutil.which('ffmpeg'), '-loglevel', 'quiet' ] + commands
return subprocess.Popen(commands, stdin = subprocess.PIPE, stdout = subprocess.PIPE)
diff --git a/facefusion/typing.py b/facefusion/typing.py
index 1bc08e67..e79eb782 100755
--- a/facefusion/typing.py
+++ b/facefusion/typing.py
@@ -85,6 +85,8 @@ ProcessStep = Callable[[str, int, Args], bool]
Content = Dict[str, Any]
+Commands = List[str]
+
WarpTemplate = Literal['arcface_112_v1', 'arcface_112_v2', 'arcface_128_v2', 'dfl_whole_face', 'ffhq_512', 'mtcnn_512', 'styleganex_384']
WarpTemplateSet = Dict[WarpTemplate, NDArray[Any]]
ProcessMode = Literal['output', 'preview', 'stream']