Skip to content

Industry leading face manipulation platform

Add support for rawvideo

henryruhsb9356d50dbc6
diff --git a/facefusion/choices.py b/facefusion/choices.py
index 1a2a7a49..96dc73df 100755
--- a/facefusion/choices.py
+++ b/facefusion/choices.py
@@ -69,7 +69,7 @@ temp_frame_formats : List[ImageFormat] = [ 'bmp', 'jpeg', 'png', 'tiff' ]
output_encoder_set : EncoderSet =\
{
'audio': [ 'flac', 'aac', 'libmp3lame', 'libopus', 'libvorbis', 'pcm_s16le', 'pcm_s32le' ],
- 'video': [ 'libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc', 'h264_amf', 'hevc_amf', 'h264_qsv', 'hevc_qsv', 'h264_videotoolbox', 'hevc_videotoolbox' ]
+ 'video': [ 'libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc', 'h264_amf', 'hevc_amf', 'h264_qsv', 'hevc_qsv', 'h264_videotoolbox', 'hevc_videotoolbox', 'rawvideo' ]
}
output_audio_encoders : List[AudioEncoder] = output_encoder_set.get('audio')
output_video_encoders : List[VideoEncoder] = output_encoder_set.get('video')
diff --git a/facefusion/ffmpeg.py b/facefusion/ffmpeg.py
index 31af6f83..91c8bb3d 100644
--- a/facefusion/ffmpeg.py
+++ b/facefusion/ffmpeg.py
@@ -221,7 +221,7 @@ def merge_video(target_path : str, temp_video_fps : Fps, output_video_resolution
ffmpeg_builder.set_video_quality(output_video_encoder, output_video_quality),
ffmpeg_builder.set_video_preset(output_video_encoder, output_video_preset),
ffmpeg_builder.set_video_fps(output_video_fps),
- ffmpeg_builder.set_pixel_format('yuv420p'),
+ ffmpeg_builder.set_pixel_format(output_video_encoder),
ffmpeg_builder.set_video_colorspace('bt709'),
ffmpeg_builder.force_output(temp_file_path)
)
diff --git a/facefusion/ffmpeg_builder.py b/facefusion/ffmpeg_builder.py
index 9004fd1a..dd96a7ca 100644
--- a/facefusion/ffmpeg_builder.py
+++ b/facefusion/ffmpeg_builder.py
@@ -56,8 +56,10 @@ def unsafe_concat() -> Commands:
return [ '-f', 'concat', '-safe', '0' ]
-def set_pixel_format(pixel_format : str) -> Commands:
- return [ '-pix_fmt', pixel_format ]
+def set_pixel_format(video_encoder : VideoEncoder) -> Commands:
+ if video_encoder == 'rawvideo':
+ return [ '-pix_fmt', 'rgb24' ]
+ return [ '-pix_fmt', 'yuv420p' ]
def set_frame_quality(frame_quality : int) -> Commands:
diff --git a/facefusion/types.py b/facefusion/types.py
index 2b2ea543..0b7a42d1 100755
--- a/facefusion/types.py
+++ b/facefusion/types.py
@@ -117,8 +117,8 @@ AudioTypeSet : TypeAlias = Dict[AudioFormat, str]
ImageTypeSet : TypeAlias = Dict[ImageFormat, str]
VideoTypeSet : TypeAlias = Dict[VideoFormat, str]
-AudioEncoder = Literal['aac', 'libmp3lame', 'libopus', 'libvorbis', 'flac', 'pcm_s16le', 'pcm_s32le']
-VideoEncoder = Literal['libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc', 'h264_amf', 'hevc_amf', 'h264_qsv', 'hevc_qsv', 'h264_videotoolbox', 'hevc_videotoolbox']
+AudioEncoder = Literal['flac', 'aac', 'libmp3lame', 'libopus', 'libvorbis', 'pcm_s16le', 'pcm_s32le']
+VideoEncoder = Literal['libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc', 'h264_amf', 'hevc_amf', 'h264_qsv', 'hevc_qsv', 'h264_videotoolbox', 'hevc_videotoolbox', 'rawvideo']
EncoderSet = TypedDict('EncoderSet',
{
'audio' : List[AudioEncoder],