Added informative messages and improved error handling for ffmpeg

This commit is contained in:
Deniz Şafak
2025-05-04 00:03:53 +03:00
parent 4311ed51d4
commit 13cf6f20a4
+10 -6
View File
@@ -634,14 +634,18 @@ class ConversionThread(QThread):
"-map_chapters", "1", "-map_chapters", "1",
out_path_m4b out_path_m4b
] ]
try:
self.log_updated.emit("Adding chapters to the audio file...\n")
result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True) result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True)
# TODO Check for errors in the ffmpeg command # Check for errors in the ffmpeg command
except subprocess.CalledProcessError as e: if result.returncode != 0:
self.log_updated.emit( self.log_updated.emit((f"FFmpeg error: {result.stderr}", "red"))
(f"FFmpeg error: {e.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 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 # delete the chapters path and original (wav) file
os.remove(chapters_info_path) os.remove(chapters_info_path)
os.remove(out_path) os.remove(out_path)