Add video encoder via CLI
This commit is contained in:
parent
e37fa75522
commit
60128d3e96
19
README.md
19
README.md
@ -34,23 +34,28 @@ Additional command line arguments are given below:
|
|||||||
```
|
```
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-f SOURCE_IMG, --face SOURCE_IMG
|
-f SOURCE_PATH, --face SOURCE_PATH
|
||||||
use this face
|
use a face image
|
||||||
-t TARGET_PATH, --target TARGET_PATH
|
-t TARGET_PATH, --target TARGET_PATH
|
||||||
replace this face
|
replace image or video with face
|
||||||
-o OUTPUT_FILE, --output OUTPUT_FILE
|
-o OUTPUT_PATH, --output OUTPUT_PATH
|
||||||
save output to this file
|
save output to this file
|
||||||
--keep-fps maintain original fps
|
--keep-fps maintain original fps
|
||||||
|
--keep-audio maintain original audio
|
||||||
--keep-frames keep frames directory
|
--keep-frames keep frames directory
|
||||||
--all-faces swap all faces in frame
|
--many-faces swap every face in the frame
|
||||||
|
--video-encoder VIDEO_ENCODER
|
||||||
|
adjust output video encoder
|
||||||
|
--video-quality VIDEO_QUALITY
|
||||||
|
adjust output video quality
|
||||||
--max-memory MAX_MEMORY
|
--max-memory MAX_MEMORY
|
||||||
maximum amount of RAM in GB to be used
|
maximum amount of RAM in GB to be used
|
||||||
--cpu-cores CPU_CORES
|
--cpu-cores CPU_CORES
|
||||||
number of CPU cores to use
|
number of CPU cores to use
|
||||||
--gpu-threads GPU_THREADS
|
--gpu-threads GPU_THREADS
|
||||||
number of threads to be use for the GPU
|
number of threads to be use for the GPU
|
||||||
--gpu-vendor {apple,amd,intel,nvidia}
|
--gpu-vendor {apple,amd,nvidia}
|
||||||
choice your GPU vendor
|
select your GPU vendor
|
||||||
```
|
```
|
||||||
|
|
||||||
Looking for a CLI mode? Using the -f/--face argument will make the program in cli mode.
|
Looking for a CLI mode? Using the -f/--face argument will make the program in cli mode.
|
||||||
|
@ -42,7 +42,8 @@ def parse_args() -> None:
|
|||||||
parser.add_argument('--keep-audio', help='maintain original audio', dest='keep_audio', action='store_true', default=True)
|
parser.add_argument('--keep-audio', help='maintain original audio', dest='keep_audio', action='store_true', default=True)
|
||||||
parser.add_argument('--keep-frames', help='keep frames directory', dest='keep_frames', action='store_true', default=False)
|
parser.add_argument('--keep-frames', help='keep frames directory', dest='keep_frames', action='store_true', default=False)
|
||||||
parser.add_argument('--many-faces', help='swap every face in the frame', dest='many_faces', action='store_true', default=False)
|
parser.add_argument('--many-faces', help='swap every face in the frame', dest='many_faces', action='store_true', default=False)
|
||||||
parser.add_argument('--video-quality', help='adjust video quality of output file', dest='video_quality', type=int, default=10)
|
parser.add_argument('--video-encoder', help='adjust output video encoder', dest='video_encoder', default='libx264')
|
||||||
|
parser.add_argument('--video-quality', help='adjust output video quality', dest='video_quality', type=int, default=10)
|
||||||
parser.add_argument('--max-memory', help='maximum amount of RAM in GB to be used', dest='max_memory', type=int)
|
parser.add_argument('--max-memory', help='maximum amount of RAM in GB to be used', dest='max_memory', type=int)
|
||||||
parser.add_argument('--cpu-cores', help='number of CPU cores to use', dest='cpu_cores', type=int, default=max(psutil.cpu_count() / 2, 1))
|
parser.add_argument('--cpu-cores', help='number of CPU cores to use', dest='cpu_cores', type=int, default=max(psutil.cpu_count() / 2, 1))
|
||||||
parser.add_argument('--gpu-threads', help='number of threads to be use for the GPU', dest='gpu_threads', type=int, default=8)
|
parser.add_argument('--gpu-threads', help='number of threads to be use for the GPU', dest='gpu_threads', type=int, default=8)
|
||||||
@ -58,6 +59,7 @@ def parse_args() -> None:
|
|||||||
roop.globals.keep_audio = args.keep_audio
|
roop.globals.keep_audio = args.keep_audio
|
||||||
roop.globals.keep_frames = args.keep_frames
|
roop.globals.keep_frames = args.keep_frames
|
||||||
roop.globals.many_faces = args.many_faces
|
roop.globals.many_faces = args.many_faces
|
||||||
|
roop.globals.video_encoder = args.video_encoder
|
||||||
roop.globals.video_quality = args.video_quality
|
roop.globals.video_quality = args.video_quality
|
||||||
|
|
||||||
if args.cpu_cores:
|
if args.cpu_cores:
|
||||||
|
@ -7,6 +7,7 @@ keep_fps = None
|
|||||||
keep_audio = None
|
keep_audio = None
|
||||||
keep_frames = None
|
keep_frames = None
|
||||||
many_faces = None
|
many_faces = None
|
||||||
|
video_encoder = None
|
||||||
video_quality = None
|
video_quality = None
|
||||||
cpu_cores = None
|
cpu_cores = None
|
||||||
gpu_threads = None
|
gpu_threads = None
|
||||||
|
@ -35,7 +35,7 @@ def extract_frames(target_path: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def create_video(target_path: str, fps: int) -> None:
|
def create_video(target_path: str, fps: int) -> None:
|
||||||
run_ffmpeg(['-i', get_temp_directory_path(target_path) + os.sep + '%04d.png', '-framerate', str(fps), '-c:v', 'libx264', '-crf', str(roop.globals.video_quality), '-pix_fmt', 'yuv420p', '-y', get_temp_file_path(target_path)])
|
run_ffmpeg(['-i', get_temp_directory_path(target_path) + os.sep + '%04d.png', '-framerate', str(fps), '-c:v', roop.globals.video_encoder, '-crf', str(roop.globals.video_quality), '-pix_fmt', 'yuv420p', '-y', get_temp_file_path(target_path)])
|
||||||
|
|
||||||
|
|
||||||
def restore_audio(target_path: str, output_path: str) -> None:
|
def restore_audio(target_path: str, output_path: str) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user