mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-27 12:30:55 +02:00
support for rgba via stream
This commit is contained in:
@@ -169,7 +169,8 @@ def create_video_writer_process(target_path : str, temp_video_fps : Fps, temp_vi
|
||||
encoder_thread_count = 16
|
||||
commands = ffmpeg_builder.chain(
|
||||
ffmpeg_builder.set_output_format('rawvideo'),
|
||||
ffmpeg_builder.enforce_pixel_format('bgr24'),
|
||||
#todo: consider to introduce a argument to pass --output-pixel-format
|
||||
ffmpeg_builder.enforce_pixel_format('bgra'),
|
||||
ffmpeg_builder.set_media_resolution(pack_video_resolution(temp_video_resolution)),
|
||||
ffmpeg_builder.set_input_fps(temp_video_fps),
|
||||
ffmpeg_builder.set_input('pipe:0'),
|
||||
|
||||
@@ -114,7 +114,7 @@ def process_stream_frames() -> ErrorCode:
|
||||
#todo: needs review - [memory] [critical: high] frame look ahead bound by hardcoded 3gb budget, extract into a dedicated method
|
||||
width, height = temp_video_resolution
|
||||
frame_memory_budget = 3 * 1024 ** 3
|
||||
frame_memory_usage = width * height * 3 * 6
|
||||
frame_memory_usage = width * height * 4 * 6
|
||||
frame_look_ahead = min(state_manager.get_item('execution_thread_count') * 2, max(2, frame_memory_budget // frame_memory_usage))
|
||||
|
||||
for frame_number in frame_range:
|
||||
@@ -279,7 +279,7 @@ def process_disk_frames() -> ErrorCode:
|
||||
return 0
|
||||
|
||||
|
||||
#todo: needs review - [streaming] [critical: high] middle frame resized to temp resolution before processing, returns contiguous bgr copy
|
||||
#todo: needs review - [streaming] [critical: high] middle frame resized to temp resolution before processing, returns contiguous bgra matching the writer pipe
|
||||
def process_stream_frame(frame_number : int, temp_video_resolution : Resolution) -> Tuple[int, VisionFrame]:
|
||||
target_vision_frames = select_video_frames(state_manager.get_item('target_path'), frame_number, state_manager.get_item('target_frame_amount'))
|
||||
target_vision_frame = get_middle(target_vision_frames)
|
||||
@@ -288,7 +288,11 @@ def process_stream_frame(frame_number : int, temp_video_resolution : Resolution)
|
||||
if not (target_vision_frame.shape[1], target_vision_frame.shape[0]) == temp_video_resolution:
|
||||
temp_vision_frame = cv2.resize(target_vision_frame, temp_video_resolution)
|
||||
temp_vision_frame = process_target_frame(frame_number, target_vision_frames, temp_vision_frame)
|
||||
return frame_number, numpy.ascontiguousarray(temp_vision_frame[:, :, :3])
|
||||
|
||||
if temp_vision_frame.shape[2] == 3:
|
||||
temp_vision_frame = cv2.cvtColor(temp_vision_frame, cv2.COLOR_BGR2BGRA)
|
||||
|
||||
return frame_number, numpy.ascontiguousarray(temp_vision_frame)
|
||||
|
||||
|
||||
def finalize_video(start_time : float) -> ErrorCode:
|
||||
|
||||
Reference in New Issue
Block a user