mirror of
https://github.com/s0md3v/roop.git
synced 2025-12-06 18:08:29 +00:00
Support selecting intermediate image format
This commit is contained in:
parent
41e8825c59
commit
c1ae1fcdc1
@ -45,6 +45,7 @@ def parse_args() -> None:
|
||||
parser.add_argument('--max-memory', help='maximum amount of RAM in GB', dest='max_memory', type=int, default=suggest_max_memory())
|
||||
parser.add_argument('--execution-provider', help='execution provider', dest='execution_provider', default=['cpu'], choices=suggest_execution_providers(), nargs='+')
|
||||
parser.add_argument('--execution-threads', help='number of execution threads', dest='execution_threads', type=int, default=suggest_execution_threads())
|
||||
parser.add_argument('--image-format', help='adjust intermediate image format', dest='image_format', default='png', choices=['png', 'jpg'])
|
||||
|
||||
# register deprecated args
|
||||
parser.add_argument('-f', '--face', help=argparse.SUPPRESS, dest='source_path_deprecated')
|
||||
@ -68,6 +69,7 @@ def parse_args() -> None:
|
||||
roop.globals.max_memory = args.max_memory
|
||||
roop.globals.execution_providers = decode_execution_providers(args.execution_provider)
|
||||
roop.globals.execution_threads = args.execution_threads
|
||||
roop.globals.image_format = args.image_format
|
||||
|
||||
# warn and cast deprecated args
|
||||
if args.source_path_deprecated:
|
||||
|
||||
@ -11,5 +11,6 @@ video_quality = None
|
||||
max_memory = None
|
||||
execution_providers = []
|
||||
execution_threads = None
|
||||
image_format = None
|
||||
headless = None
|
||||
log_level = 'error'
|
||||
|
||||
@ -42,13 +42,13 @@ def detect_fps(target_path: str) -> float:
|
||||
|
||||
def extract_frames(target_path: str) -> None:
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
run_ffmpeg(['-i', target_path, os.path.join(temp_directory_path, '%04d.png')])
|
||||
run_ffmpeg(['-i', target_path, '-qscale:v', '1', os.path.join(temp_directory_path, '%04d.' + roop.globals.image_format)])
|
||||
|
||||
|
||||
def create_video(target_path: str, fps: float = 30.0) -> None:
|
||||
temp_output_path = get_temp_output_path(target_path)
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
run_ffmpeg(['-r', str(fps), '-i', os.path.join(temp_directory_path, '%04d.png'), '-c:v', roop.globals.video_encoder, '-crf', str(roop.globals.video_quality), '-pix_fmt', 'yuv420p', '-y', temp_output_path])
|
||||
run_ffmpeg(['-r', str(fps), '-i', os.path.join(temp_directory_path, '%04d.' + roop.globals.image_format), '-c:v', roop.globals.video_encoder, '-crf', str(roop.globals.video_quality), '-pix_fmt', 'yuv420p', '-y', temp_output_path])
|
||||
|
||||
|
||||
def restore_audio(target_path: str, output_path: str) -> None:
|
||||
@ -60,7 +60,7 @@ def restore_audio(target_path: str, output_path: str) -> None:
|
||||
|
||||
def get_temp_frame_paths(target_path: str) -> List[str]:
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
return glob.glob(os.path.join(temp_directory_path, '*.png'))
|
||||
return glob.glob(os.path.join(temp_directory_path, '*.' + roop.globals.image_format))
|
||||
|
||||
|
||||
def get_temp_directory_path(target_path: str) -> str:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user