From 13cf6f20a44078ca3dd1c4267ae8e48e527f7058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Sun, 4 May 2025 00:03:53 +0300 Subject: [PATCH] Added informative messages and improved error handling for ffmpeg --- abogen/conversion.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/abogen/conversion.py b/abogen/conversion.py index 21597f2..2e2610b 100644 --- a/abogen/conversion.py +++ b/abogen/conversion.py @@ -634,14 +634,18 @@ class ConversionThread(QThread): "-map_chapters", "1", out_path_m4b ] - try: - result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True) - # TODO Check for errors in the ffmpeg command - except subprocess.CalledProcessError as e: - self.log_updated.emit( - (f"FFmpeg error: {e.stderr}", "red") - ) + + self.log_updated.emit("Adding chapters to the audio file...\n") + result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True) + # Check for errors in the ffmpeg command + if result.returncode != 0: + self.log_updated.emit((f"FFmpeg error: {result.stderr}", "red")) + # Log error but continue with original file + self.log_updated.emit(("Falling back to the original audio file without chapters\n", "orange")) return out_path + else: + self.log_updated.emit(("Successfully added chapters to the audio file.\n", "green")) + # delete the chapters path and original (wav) file os.remove(chapters_info_path) os.remove(out_path)