From d57279ceb653331bb04d588579eb7ed1c8e4c431 Mon Sep 17 00:00:00 2001 From: NickPittas <107440357+NickPittas@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:05:46 +0300 Subject: [PATCH] Update utilities.py (#542) Updated the extraction process with the ffmpeg command that corrects the colorspace while extracting to png, and corrected the ffmpeg command, adding '-pix_fmt', 'rgb24', '-sws_flags', '+accurate_rnd+full_chroma_int', '-colorspace', '1', '-color_primaries', '1', '-color_trc', '1' '-pix_fmt rgb24', means treat the image as RGB (or RGBA) '-sws_flags +accurate_rnd+full_chroma_int', means use full color and chroma subsampling instead of 4:2:0 '-colorspace 1', '-color_primaries 1', '-color_trc 1' put the metadata color tags to the png --- roop/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roop/utilities.py b/roop/utilities.py index 9349fa6..28b1a36 100644 --- a/roop/utilities.py +++ b/roop/utilities.py @@ -44,7 +44,7 @@ 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, '-pix_fmt', 'rgb24', '-sws_flags', '+accurate_rnd+full_chroma_int', '-colorspace', '1', '-color_primaries', '1', '-color_trc', '1', os.path.join(temp_directory_path, '%04d.png')]) def create_video(target_path: str, fps: float = 30.0) -> None: