From a3fd56a3126573e8ce6d59d1f794e47c4ce0db19 Mon Sep 17 00:00:00 2001 From: Karl Date: Wed, 1 Apr 2026 15:22:09 +0800 Subject: [PATCH 1/2] Fix missing video output reporting and encoding flow --- modules/core.py | 10 +++++++--- modules/utilities.py | 17 +++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/core.py b/modules/core.py index 663d742..f91835e 100644 --- a/modules/core.py +++ b/modules/core.py @@ -251,11 +251,15 @@ def start() -> None: update_status('Detecting fps...') fps = detect_fps(modules.globals.target_path) update_status(f'Creating video with {fps} fps...') - create_video(modules.globals.target_path, fps) + video_created = create_video(modules.globals.target_path, fps) else: update_status('Creating video with 30.0 fps...') - create_video(modules.globals.target_path) + video_created = create_video(modules.globals.target_path) encoding_time = time.time() - encoding_start + if not video_created: + update_status('Video encoding failed. No temporary output video was created.') + clean_temp(modules.globals.target_path) + return update_status(f'Video encoding completed in {encoding_time:.2f}s') # handle audio @@ -272,7 +276,7 @@ def start() -> None: clean_temp(modules.globals.target_path) total_time = time.time() - start_time - if is_video(modules.globals.target_path): + if is_video(modules.globals.target_path) and modules.globals.output_path and os.path.isfile(modules.globals.output_path): update_status(f'Processing to video succeed! Total time: {total_time:.2f}s') else: update_status('Processing to video failed!') diff --git a/modules/utilities.py b/modules/utilities.py index 2638465..d99e74d 100644 --- a/modules/utilities.py +++ b/modules/utilities.py @@ -30,8 +30,12 @@ def run_ffmpeg(args: List[str]) -> bool: try: subprocess.check_output(commands, stderr=subprocess.STDOUT) return True - except Exception: - pass + except subprocess.CalledProcessError as error: + output = error.output.decode(errors="ignore").strip() + if output: + print(output) + except Exception as error: + print(f"ffmpeg execution failed: {error}") return False @@ -61,19 +65,19 @@ def extract_frames(target_path: str) -> None: """Extract frames with hardware acceleration and optimized settings.""" temp_directory_path = get_temp_directory_path(target_path) - # Use hardware-accelerated decoding and optimized pixel format + # Write a contiguous image sequence so the later "%04d.png" input pattern + # used during encoding can consume every frame reliably. run_ffmpeg( [ "-i", target_path, "-vf", "format=rgb24", # Use video filter for format conversion (faster) "-vsync", "0", # Prevent frame duplication - "-frame_pts", "1", # Preserve frame timing os.path.join(temp_directory_path, "%04d.png"), ] ) -def create_video(target_path: str, fps: float = 30.0) -> None: +def create_video(target_path: str, fps: float = 30.0) -> bool: """Create video with hardware-accelerated encoding and optimized settings.""" temp_output_path = get_temp_output_path(target_path) temp_directory_path = get_temp_directory_path(target_path) @@ -182,7 +186,8 @@ def create_video(target_path: str, fps: float = 30.0) -> None: "-y", temp_output_path, ] - run_ffmpeg(ffmpeg_args_fallback) + success = run_ffmpeg(ffmpeg_args_fallback) + return success and os.path.isfile(temp_output_path) def restore_audio(target_path: str, output_path: str) -> None: From bb4ef4a133bb27b411ac3d5587d7add4090120f5 Mon Sep 17 00:00:00 2001 From: Kenneth Estanislao Date: Wed, 1 Apr 2026 23:13:59 +0800 Subject: [PATCH 2/2] Apply suggestion from @sourcery-ai[bot] Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- modules/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core.py b/modules/core.py index f91835e..67eece1 100644 --- a/modules/core.py +++ b/modules/core.py @@ -277,7 +277,7 @@ def start() -> None: total_time = time.time() - start_time if is_video(modules.globals.target_path) and modules.globals.output_path and os.path.isfile(modules.globals.output_path): - update_status(f'Processing to video succeed! Total time: {total_time:.2f}s') + update_status(f'Video processing succeeded! Total time: {total_time:.2f}s') else: update_status('Processing to video failed!')