From cf5f27d36a15baccf505608965b4f3b55c0a983a Mon Sep 17 00:00:00 2001 From: NickPittas <107440357+NickPittas@users.noreply.github.com> Date: Mon, 19 Jun 2023 22:35:08 +0300 Subject: [PATCH] Fixing the colorspace issue when writing the mp4 from the extracted pngs (#550) * Update utilities.py 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 * Fixing color conversion from temp png sequence to mp4 '-sws_flags', 'spline+accurate_rnd+full_chroma_int', ' use full color and chroma subsampling -vf', 'colorspace=bt709:iall=bt601-6-625:fast=1', keep the same rec709 colorspace '-color_range', '1', '-colorspace', '1', '-color_primaries', '1', '-color_trc', '1', put the metadata color tags to the mp4 --- roop/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roop/utilities.py b/roop/utilities.py index 28b1a36..4e1be39 100644 --- a/roop/utilities.py +++ b/roop/utilities.py @@ -50,7 +50,7 @@ def extract_frames(target_path: str) -> None: 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.png'), '-c:v', roop.globals.video_encoder, '-crf', str(roop.globals.video_quality), '-y', '-pix_fmt', 'yuv420p10le', '-sws_flags', 'spline+accurate_rnd+full_chroma_int', '-vf', 'colorspace=bt709:iall=bt601-6-625:fast=1', '-color_range', '1', '-colorspace', '1', '-color_primaries', '1', '-color_trc', '1', temp_output_path]) def restore_audio(target_path: str, output_path: str) -> None: